Read raw chunk data from the storage file.
(sampleIdx uint64)
| 173 | |
| 174 | // Read raw chunk data from the storage file. |
| 175 | func (df *DataFile) ReadSample(sampleIdx uint64) (common.Hash, error) { |
| 176 | if !df.ContainsSample(sampleIdx) { |
| 177 | return common.Hash{}, fmt.Errorf("sample not found") |
| 178 | } |
| 179 | sampleSize := 1 << SampleSizeBits |
| 180 | md := make([]byte, sampleSize) |
| 181 | n, err := df.file.ReadAt(md, HEADER_SIZE+int64(sampleIdx<<SampleSizeBits)-int64(df.chunkIdxStart*df.chunkSize)) |
| 182 | if err != nil { |
| 183 | return common.Hash{}, err |
| 184 | } |
| 185 | if n != sampleSize { |
| 186 | return common.Hash{}, fmt.Errorf("not full read") |
| 187 | } |
| 188 | return common.BytesToHash(md), nil |
| 189 | } |
| 190 | |
| 191 | // Write the chunk bytes to the file. |
| 192 | func (df *DataFile) Write(chunkIdx uint64, b []byte) error { |
nothing calls this directly
no test coverage detected