From 7fad4ab2e6500d9c1af3c6d788ce9c29788c474b Mon Sep 17 00:00:00 2001 From: Calin Martinconi Date: Mon, 29 Jul 2024 16:22:49 +0300 Subject: [PATCH] fix: stewardship api doesn't check final leaves (#4735) --- pkg/steward/steward.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/steward/steward.go b/pkg/steward/steward.go index 9c099dd3624..9726ed1baa3 100644 --- a/pkg/steward/steward.go +++ b/pkg/steward/steward.go @@ -34,6 +34,7 @@ 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 { @@ -41,6 +42,7 @@ func New(ns storer.NetStore, r retrieval.Interface, joinerPutter storage.Putter) netStore: ns, traverser: traversal.New(ns.Download(true), joinerPutter), netTraverser: traversal.New(&netGetter{r}, joinerPutter), + netGetter: r, } } @@ -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):