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

Method TryEncodeKV

ethstorage/shard_manager.go:188–197  ·  view source on GitHub ↗

TryEncodeKV encode the KV data using the miner and encodeType specified by the data shard. Return false if the data is not managed by the ShardManager.

(kvIdx uint64, b []byte, hash common.Hash)

Source from the content-addressed store, hash-verified

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.
188func (sm *ShardManager) TryEncodeKV(kvIdx uint64, b []byte, hash common.Hash) ([]byte, bool, error) {
189 shardIdx := kvIdx / sm.kvEntries
190 if ds, ok := sm.shardMap[shardIdx]; ok {
191 cb := make([]byte, ds.kvSize)
192 copy(cb, b)
193 return sm.EncodeKV(kvIdx, cb, hash, ds.Miner(), ds.EncodeType())
194 } else {
195 return nil, false, nil
196 }
197}
198
199// TryReadWithMeta Read the encoded KV data and meta from storage file and decode it.
200// Return error if the read IO fails.

Callers 3

CommitBlobsMethod · 0.80
CommitEmptyBlobsMethod · 0.80
CommitBlobMethod · 0.80

Calls 3

EncodeKVMethod · 0.95
EncodeTypeMethod · 0.80
MinerMethod · 0.45

Tested by

no test coverage detected