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

Method ReadChunk

ethstorage/data_shard.go:122–127  ·  view source on GitHub ↗

ReadChunk read the encoded data from storage and decode it.

(kvIdx uint64, chunkIdx uint64, commit common.Hash)

Source from the content-addressed store, hash-verified

120
121// ReadChunk read the encoded data from storage and decode it.
122func (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.
130func (ds *DataShard) readChunkWith(kvIdx uint64, chunkIdx uint64, decoder func([]byte, uint64) []byte) ([]byte, error) {

Callers 1

TryReadChunkMethod · 0.80

Calls 3

readChunkWithMethod · 0.95
calcEncodeKeyFunction · 0.85
decodeChunkFunction · 0.85

Tested by

no test coverage detected