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

Method Read

ethstorage/data_shard.go:154–167  ·  view source on GitHub ↗

Read the encoded data from storage and decode it.

(kvIdx uint64, readLen int, commit common.Hash)

Source from the content-addressed store, hash-verified

152
153// Read the encoded data from storage and decode it.
154func (ds *DataShard) Read(kvIdx uint64, readLen int, commit common.Hash) ([]byte, error) {
155 bs, err := ds.readWith(kvIdx, int(ds.kvSize), func(cdata []byte, chunkIdx uint64) []byte {
156 encodeKey := calcEncodeKey(commit, chunkIdx, ds.dataFiles[0].miner)
157 return decodeChunk(ds.chunkSize, cdata, ds.dataFiles[0].encodeType, encodeKey)
158 })
159 if err != nil {
160 return nil, err
161 }
162
163 if err = checkCommit(commit, bs); err != nil {
164 return nil, err
165 }
166 return bs[0:readLen], nil
167}
168
169// Read the encoded data from storage and decode it.
170func (ds *DataShard) ReadWithMeta(kvIdx uint64, readLen int) ([]byte, []byte, error) {

Callers

nothing calls this directly

Calls 4

readWithMethod · 0.95
calcEncodeKeyFunction · 0.85
decodeChunkFunction · 0.85
checkCommitFunction · 0.85

Tested by

no test coverage detected