(epoch uint64, chunkHash common.Hash, maxKvSize uint64, sizeInChunk int, maskBuffer []byte)
| 52 | } |
| 53 | |
| 54 | func GetMaskDataWithInChunk(epoch uint64, chunkHash common.Hash, maxKvSize uint64, sizeInChunk int, maskBuffer []byte) []byte { |
| 55 | |
| 56 | if sizeInChunk > int(CHUNK_SIZE) { |
| 57 | panic("sizeInChunk > CHUNK_SIZE") |
| 58 | } |
| 59 | if len(maskBuffer) != sizeInChunk { |
| 60 | maskBuffer = make([]byte, sizeInChunk) |
| 61 | } |
| 62 | |
| 63 | cache := Cache(epoch) |
| 64 | size := pora.DatasetSizeForEpoch(epoch) |
| 65 | |
| 66 | realHash := make([]byte, len(chunkHash)+8) |
| 67 | copy(realHash, chunkHash[:]) |
| 68 | |
| 69 | for i := 0; i < sizeInChunk/pora.GetMixBytes(); i++ { |
| 70 | ToRealHash(chunkHash, maxKvSize, uint64(i), realHash, false) |
| 71 | mask := pora.HashimotoForMaskLight(size, cache.Cache, realHash) |
| 72 | if len(mask) != pora.GetMixBytes() { |
| 73 | panic("#mask != MixBytes") |
| 74 | } |
| 75 | copy(maskBuffer[i*pora.GetMixBytes():], mask) |
| 76 | } |
| 77 | |
| 78 | tailBytes := sizeInChunk % pora.GetMixBytes() |
| 79 | if tailBytes > 0 { |
| 80 | i := sizeInChunk / pora.GetMixBytes() |
| 81 | ToRealHash(chunkHash, maxKvSize, uint64(i), realHash, false) |
| 82 | mask := pora.HashimotoForMaskLight(size, cache.Cache, realHash) |
| 83 | if len(mask) != pora.GetMixBytes() { |
| 84 | panic("#mask != MixBytes") |
| 85 | } |
| 86 | copy(maskBuffer[i*pora.GetMixBytes():], mask) |
| 87 | } |
| 88 | |
| 89 | return maskBuffer |
| 90 | } |
| 91 | |
| 92 | func GetMaskData(epoch uint64, encodeKey common.Hash, chunkSize int, maskBuffer []byte) []byte { |
| 93 | if len(maskBuffer) != chunkSize { |
nothing calls this directly
no test coverage detected