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

Function GetMaskData

ethstorage/pora/ethash.go:92–113  ·  view source on GitHub ↗
(epoch uint64, encodeKey common.Hash, chunkSize int, maskBuffer []byte)

Source from the content-addressed store, hash-verified

90}
91
92func GetMaskData(epoch uint64, encodeKey common.Hash, chunkSize int, maskBuffer []byte) []byte {
93 if len(maskBuffer) != chunkSize {
94 maskBuffer = make([]byte, chunkSize)
95 }
96
97 cache := Cache(epoch)
98 size := pora.DatasetSizeForEpoch(epoch)
99
100 realHash := make([]byte, len(encodeKey)+8)
101 copy(realHash, encodeKey[:])
102
103 for i := 0; i < (chunkSize+pora.GetMixBytes()-1)/pora.GetMixBytes(); i++ {
104 binary.BigEndian.PutUint64(realHash[len(encodeKey):], uint64(i))
105 mask := pora.HashimotoForMaskLight(size, cache.Cache, realHash)
106 if len(mask) != pora.GetMixBytes() {
107 panic("#mask != MixBytes")
108 }
109 copy(maskBuffer[i*pora.GetMixBytes():], mask)
110 }
111
112 return maskBuffer
113}

Callers 3

encodeChunkFunction · 0.92
decodeChunkFunction · 0.92
TestMaskDataFunction · 0.85

Calls 1

CacheFunction · 0.70

Tested by 1

TestMaskDataFunction · 0.68