Skip to content

Commit

Permalink
Add a flag to skip multihash mismatch errors
Browse files Browse the repository at this point in the history
Any error returned by the link system other than ipld.ErrNotExists results into IPNI halting ingestion of such adchain. The new configuration option will allow boost to "skip" such advertisements instead without affecting the rest of the chain.
  • Loading branch information
ischasny committed Dec 5, 2023
1 parent 791a485 commit 4623db8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engine/linksystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ func (e *Engine) mkLinkSystem() ipld.LinkSystem {
}
if regeneratedLink == nil || !c.Equals(regeneratedLink.(cidlink.Link).Cid) {
log.Errorw("Regeneration of entries link from multihash iterator did not match the original link. Check that multihash iterator consistently returns the same entries for the same key.", "want", lnk, "got", regeneratedLink)
return nil, ErrEntriesLinkMismatch
if e.skipMultihashMismatchErros {
return nil, ipld.ErrNotExists{}
} else {
return nil, ErrEntriesLinkMismatch
}
}
} else {
log.Debugw("Found cache entry for CID", "cid", c)
Expand Down
12 changes: 12 additions & 0 deletions engine/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ type (
purgeCache bool
chunker chunker.NewChunkerFunc

skipMultihashMismatchErros bool

syncPolicy *policy.Policy
}
)
Expand Down Expand Up @@ -442,3 +444,13 @@ func WithExtraGossipData(extraData []byte) Option {
return nil
}
}

// WithSkipMultihashMismatchErros instructs the underlying link system to skip multihash mismatch errors
// and return ipld.ErrNotExists if such occur. ipld.ErrNotExists is treated as content not found and will result to
// 404 returned back to IPNI.
func WithSkipMultihashMismatchErros(b bool) Option {
return func(o *options) error {
o.skipMultihashMismatchErros = b
return nil
}
}

0 comments on commit 4623db8

Please sign in to comment.