Skip to content

Commit

Permalink
fix: stewardship api doesn't check final leaves (#4735)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinconic authored Jul 29, 2024
1 parent dac77a5 commit 7fad4ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/steward/steward.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ type steward struct {
netStore storer.NetStore
traverser traversal.Traverser
netTraverser traversal.Traverser
netGetter retrieval.Interface
}

func New(ns storer.NetStore, r retrieval.Interface, joinerPutter storage.Putter) Interface {
return &steward{
netStore: ns,
traverser: traversal.New(ns.Download(true), joinerPutter),
netTraverser: traversal.New(&netGetter{r}, joinerPutter),
netGetter: r,
}
}

Expand Down Expand Up @@ -79,8 +81,11 @@ func (s *steward) Reupload(ctx context.Context, root swarm.Address, stamper post

// IsRetrievable implements Interface.IsRetrievable method.
func (s *steward) IsRetrievable(ctx context.Context, root swarm.Address) (bool, error) {
noop := func(leaf swarm.Address) error { return nil }
switch err := s.netTraverser.Traverse(ctx, root, noop); {
fn := func(a swarm.Address) error {
_, err := s.netGetter.RetrieveChunk(ctx, a, swarm.ZeroAddress)
return err
}
switch err := s.netTraverser.Traverse(ctx, root, fn); {
case errors.Is(err, storage.ErrNotFound):
return false, nil
case errors.Is(err, topology.ErrNotFound):
Expand Down

0 comments on commit 7fad4ab

Please sign in to comment.