Skip to content

Commit

Permalink
Merge pull request #223 from SiaFoundation/nate/add-sector-context
Browse files Browse the repository at this point in the history
Add root to read sector error context
  • Loading branch information
n8maninger authored Dec 2, 2023
2 parents c1988d7 + 5143891 commit b59d0f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions host/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ func (vm *VolumeManager) Read(root types.Hash256) (*[rhp2.SectorSize]byte, error
// Cache miss, read from disk
loc, release, err := vm.vs.SectorLocation(root)
if err != nil {
return nil, fmt.Errorf("failed to locate sector %v: %w", root, err)
return nil, fmt.Errorf("failed to locate sector: %w", err)
}
defer release()

Expand All @@ -844,7 +844,7 @@ func (vm *VolumeManager) Read(root types.Hash256) (*[rhp2.SectorSize]byte, error
vm.mu.Unlock()
sector, err := v.ReadSector(loc.Index)
if err != nil {
return nil, fmt.Errorf("failed to read sector %v: %w", root, err)
return nil, fmt.Errorf("failed to read sector data: %w", err)
}

// Add sector to cache
Expand Down
4 changes: 2 additions & 2 deletions rhp/v3/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (pe *programExecutor) executeHasSector(instr *rhp3.InstrHasSector) ([]byte,
var has bool
release, err := pe.storage.LockSector(root)
if err != nil && !errors.Is(err, storage.ErrSectorNotFound) {
return nil, nil, fmt.Errorf("failed to locate sector: %w", err)
return nil, nil, fmt.Errorf("failed to locate sector %q: %w", root, err)
} else if err == nil {
has = true
pe.releaseFuncs = append(pe.releaseFuncs, release)
Expand Down Expand Up @@ -275,7 +275,7 @@ func (pe *programExecutor) executeReadSector(instr *rhp3.InstrReadSector, log *z

sector, err := pe.storage.Read(root)
if err != nil {
return nil, nil, fmt.Errorf("failed to read sector: %w", err)
return nil, nil, fmt.Errorf("failed to read sector %q: %w", root, err)
}

// if no proof was requested, return the data
Expand Down

0 comments on commit b59d0f6

Please sign in to comment.