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)
| 159 | // Return error if the write IO fails. |
| 160 | // Return false if the data is not managed by the ShardManager. |
| 161 | func (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. |
no test coverage detected