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

Method TryRead

ethstorage/shard_manager.go:176–184  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

174// Return error if the read IO fails.
175// Return false if the data is not managed by the ShardManager.
176func (sm *ShardManager) TryRead(kvIdx uint64, readLen int, commit common.Hash) ([]byte, bool, error) {
177 shardIdx := kvIdx / sm.kvEntries
178 if ds, ok := sm.shardMap[shardIdx]; ok {
179 b, err := ds.Read(kvIdx, readLen, commit)
180 return b, true, err
181 } else {
182 return nil, false, nil
183 }
184}
185
186// TryEncodeKV encode the KV data using the miner and encodeType specified by the data shard.
187// Return false if the data is not managed by the ShardManager.

Callers

nothing calls this directly

Calls 1

ReadMethod · 0.65

Tested by

no test coverage detected