diff --git a/pkg/services/tree/sync.go b/pkg/services/tree/sync.go index 7f670795c..2d632d0eb 100644 --- a/pkg/services/tree/sync.go +++ b/pkg/services/tree/sync.go @@ -14,13 +14,21 @@ import ( "google.golang.org/grpc/credentials/insecure" ) +// ErrNotInContainer is returned when operation could not be performed +// because the node is not included in the container. +var ErrNotInContainer = errors.New("node is not in container") + // Synchronize tries to synchronize log starting from the last stored height. func (s *Service) Synchronize(ctx context.Context, cid cid.ID, treeID string) error { - nodes, _, err := s.getContainerNodes(cid) + nodes, pos, err := s.getContainerNodes(cid) if err != nil { return fmt.Errorf("can't get container nodes: %w", err) } + if pos < 0 { + return ErrNotInContainer + } + lm, err := s.forest.TreeGetOpLog(cid, treeID, 0) if err != nil && !errors.Is(err, pilorama.ErrTreeNotFound) { return err