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

Method TryWriteEncoded

ethstorage/shard_manager.go:161–171  ·  view source on GitHub ↗

TryWriteEncoded write the encoded data to the underly storage file directly. Return error if the write IO fails. Return false if the data is not managed by the ShardManager.

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

Source from the content-addressed store, hash-verified

159// Return error if the write IO fails.
160// Return false if the data is not managed by the ShardManager.
161func (sm *ShardManager) TryWriteEncoded(kvIdx uint64, b []byte, commit common.Hash) (bool, error) {
162 shardIdx := kvIdx / sm.kvEntries
163 if ds, ok := sm.shardMap[shardIdx]; ok {
164 err := ds.WriteWith(kvIdx, b, commit, func(cdata []byte, chunkIdx uint64) []byte {
165 return cdata
166 })
167 return true, err
168 } else {
169 return false, nil
170 }
171}
172
173// TryRead Read the encoded KV data from storage file and decode it.
174// Return error if the read IO fails.

Callers 2

DownloadFinishedMethod · 0.80
commitEncodedBlobMethod · 0.80

Calls 1

WriteWithMethod · 0.80

Tested by

no test coverage detected