Obtain a unique encoding key with keccak256(chunkIdx || commit || miner). This will make sure the encoded data will be unique in terms of idx, storage provider, and data
(commit common.Hash, chunkIdx uint64, miner common.Address)
| 232 | // Obtain a unique encoding key with keccak256(chunkIdx || commit || miner). |
| 233 | // This will make sure the encoded data will be unique in terms of idx, storage provider, and data |
| 234 | func calcEncodeKey(commit common.Hash, chunkIdx uint64, miner common.Address) common.Hash { |
| 235 | // keep the datahash and remove all the other metas |
| 236 | c := common.Hash{} |
| 237 | copy(c[0:HashSizeInContract], commit[0:HashSizeInContract]) |
| 238 | |
| 239 | bb := make([]byte, 0) |
| 240 | bb = append(bb, c.Bytes()...) |
| 241 | bb = append(bb, common.BytesToHash(miner.Bytes()).Bytes()...) |
| 242 | bb = append(bb, common.BigToHash(big.NewInt(int64(chunkIdx))).Bytes()...) |
| 243 | |
| 244 | return crypto.Keccak256Hash(bb) |
| 245 | } |
| 246 | |
| 247 | // EncodeChunk encodes bs and returned a chunk-sized encoded one |
| 248 | func EncodeChunk(chunkSize uint64, bs []byte, encodeType uint64, encodeKey common.Hash) []byte { |
no outgoing calls
no test coverage detected