MCPcopy Create free account
hub / github.com/ethstorage/es-node / calcEncodeKey

Function calcEncodeKey

ethstorage/data_shard.go:234–245  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
234func 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
248func EncodeChunk(chunkSize uint64, bs []byte, encodeType uint64, encodeKey common.Hash) []byte {

Callers 6

ReadChunkMethod · 0.85
ReadMethod · 0.85
ReadWithMetaMethod · 0.85
CalcEncodeKeyFunction · 0.85
WriteMethod · 0.85
DecodeOrEncodeKVMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected