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)
| 174 | // Return error if the read IO fails. |
| 175 | // Return false if the data is not managed by the ShardManager. |
| 176 | func (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. |