Skip to content

Commit

Permalink
Allow advertisement or entries chain truncation
Browse files Browse the repository at this point in the history
When traversing an advertisement chain or entries chain, handle a NotFound error as an indication that the chain was intentionally truncated, and ingest the portion of the chain that was found.
  • Loading branch information
gammazero committed Oct 10, 2023
1 parent b083461 commit 8198186
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dagsync/ipnisync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ func (s *Syncer) walkFetch(ctx context.Context, rootCid cid.Cid, sel selector.Se

err = progress.WalkMatching(rootNode, sel, func(_ traversal.Progress, _ datamodel.Node) error { return nil })
if err != nil {
// Advertisement or entries block, not at start of chain, was not
// found. Consider this to mean the chain was truncated at this point,
// and return what was found so far.
if errors.Is(err, ipld.ErrNotExists{}) {
log.Warnw("stopping ipld traversal due to content not found")
return traversalOrder, nil
}
return nil, err
}
return traversalOrder, nil
Expand Down

0 comments on commit 8198186

Please sign in to comment.