[#1329] tree: Do not sync trees that are from external containers

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-10-06 23:18:26 +03:00 committed by fyrchik
parent ea9a5690cb
commit f5f560d903

View file

@ -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