ReadChunk read the encoded data from storage and decode it.
(kvIdx uint64, chunkIdx uint64, commit common.Hash)
| 120 | |
| 121 | // ReadChunk read the encoded data from storage and decode it. |
| 122 | func (ds *DataShard) ReadChunk(kvIdx uint64, chunkIdx uint64, commit common.Hash) ([]byte, error) { |
| 123 | return ds.readChunkWith(kvIdx, chunkIdx, func(cdata []byte, chunkIdx uint64) []byte { |
| 124 | encodeKey := calcEncodeKey(commit, chunkIdx, ds.dataFiles[0].miner) |
| 125 | return decodeChunk(ds.chunkSize, cdata, ds.dataFiles[0].encodeType, encodeKey) |
| 126 | }) |
| 127 | } |
| 128 | |
| 129 | // readChunkWith read the encoded chunk from storage with a decoder. |
| 130 | func (ds *DataShard) readChunkWith(kvIdx uint64, chunkIdx uint64, decoder func([]byte, uint64) []byte) ([]byte, error) { |
no test coverage detected