Read raw chunk data from the storage file.
(chunkIdx uint64, len int)
| 154 | |
| 155 | // Read raw chunk data from the storage file. |
| 156 | func (df *DataFile) Read(chunkIdx uint64, len int) ([]byte, error) { |
| 157 | if !df.Contains(chunkIdx) { |
| 158 | return nil, fmt.Errorf("chunk not found") |
| 159 | } |
| 160 | if len > int(df.chunkSize) { |
| 161 | return nil, fmt.Errorf("read too large") |
| 162 | } |
| 163 | md := make([]byte, len) |
| 164 | n, err := df.file.ReadAt(md, HEADER_SIZE+int64(chunkIdx-df.chunkIdxStart)*int64(df.chunkSize)) |
| 165 | if err != nil { |
| 166 | return nil, err |
| 167 | } |
| 168 | if n != len { |
| 169 | return nil, fmt.Errorf("not full read") |
| 170 | } |
| 171 | return md, nil |
| 172 | } |
| 173 | |
| 174 | // Read raw chunk data from the storage file. |
| 175 | func (df *DataFile) ReadSample(sampleIdx uint64) (common.Hash, error) { |
no test coverage detected