check for lookback references to block headers in walk

This commit is contained in:
vyzo 2021-07-01 10:29:30 +03:00
parent 7de0771883
commit 09efed50fd

View File

@ -998,14 +998,23 @@ func (s *SplitStore) doCompact(curTs *types.TipSet) error {
}
func (s *SplitStore) walk(ts *types.TipSet, boundary abi.ChainEpoch, inclMsgs bool, f func(cid.Cid) error) error {
visited := cid.NewSet()
walked := cid.NewSet()
toWalk := ts.Cids()
walkBlock := func(c cid.Cid) error {
if !walked.Visit(c) {
if !visited.Visit(c) {
return nil
}
// check if it has been referenced by some later state root via lookback to avoid duplicate
// dispatches to the visitor
if !walked.Has(c) {
if err := f(c); err != nil {
return err
}
}
blk, err := s.get(c)
if err != nil {
return xerrors.Errorf("error retrieving block (cid: %s): %w", c, err)
@ -1021,10 +1030,6 @@ func (s *SplitStore) walk(ts *types.TipSet, boundary abi.ChainEpoch, inclMsgs bo
return nil
}
if err := f(c); err != nil {
return err
}
if hdr.Height >= boundary {
if inclMsgs {
if err := s.walkLinks(hdr.Messages, walked, f); err != nil {