Read the encoded data from storage and decode it.
(kvIdx uint64, readLen int, commit common.Hash)
| 152 | |
| 153 | // Read the encoded data from storage and decode it. |
| 154 | func (ds *DataShard) Read(kvIdx uint64, readLen int, commit common.Hash) ([]byte, error) { |
| 155 | bs, err := ds.readWith(kvIdx, int(ds.kvSize), func(cdata []byte, chunkIdx uint64) []byte { |
| 156 | encodeKey := calcEncodeKey(commit, chunkIdx, ds.dataFiles[0].miner) |
| 157 | return decodeChunk(ds.chunkSize, cdata, ds.dataFiles[0].encodeType, encodeKey) |
| 158 | }) |
| 159 | if err != nil { |
| 160 | return nil, err |
| 161 | } |
| 162 | |
| 163 | if err = checkCommit(commit, bs); err != nil { |
| 164 | return nil, err |
| 165 | } |
| 166 | return bs[0:readLen], nil |
| 167 | } |
| 168 | |
| 169 | // Read the encoded data from storage and decode it. |
| 170 | func (ds *DataShard) ReadWithMeta(kvIdx uint64, readLen int) ([]byte, []byte, error) { |
nothing calls this directly
no test coverage detected