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

Function ToRealHash

ethstorage/pora/ethash.go:32–46  ·  view source on GitHub ↗
(hash common.Hash, maxKvSize, idxWithinChunk uint64, realHash []byte, copyHash bool)

Source from the content-addressed store, hash-verified

30}
31
32func ToRealHash(hash common.Hash, maxKvSize, idxWithinChunk uint64, realHash []byte, copyHash bool) []byte {
33 if len(realHash) != len(hash)+8 {
34 realHash = make([]byte, len(hash)+8)
35 // always copy hash if newly allocated
36 copy(realHash, hash[:])
37 } else {
38 // otherwise only copy hash if requested
39 if copyHash {
40 copy(realHash, hash[:])
41 }
42 }
43
44 binary.BigEndian.PutUint64(realHash[len(hash):], maxKvSize+((idxWithinChunk+1)<<30) /* should be fine as long as MaxKvSize is < 2^30 */)
45 return realHash
46}
47
48type PhyAddr struct {
49 KvIdx uint64

Callers 1

GetMaskDataWithInChunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected