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

Method TryReadChunk

ethstorage/shard_manager.go:293–303  ·  view source on GitHub ↗

TryReadChunk Read the encoded KV data using chunkIdx from storage file and decode it. Return error if the read IO fails. Return false if the data is not managed by the ShardManager.

(chunkIdx uint64, commit common.Hash)

Source from the content-addressed store, hash-verified

291// Return error if the read IO fails.
292// Return false if the data is not managed by the ShardManager.
293func (sm *ShardManager) TryReadChunk(chunkIdx uint64, commit common.Hash) ([]byte, bool, error) {
294 kvIdx := chunkIdx / sm.chunksPerKv
295 cIdx := chunkIdx % sm.chunksPerKv
296 shardIdx := kvIdx / sm.kvEntries
297 if ds, ok := sm.shardMap[shardIdx]; ok {
298 b, err := ds.ReadChunk(kvIdx, cIdx, commit) // read all the data
299 return b, true, err
300 } else {
301 return nil, false, nil
302 }
303}
304
305// TryReadChunkEncoded Read the encoded KV data using chunkIdx from storage file and return it.
306// Return error if the read IO fails.

Callers

nothing calls this directly

Calls 1

ReadChunkMethod · 0.80

Tested by

no test coverage detected