Merge pull request #2102 from filecoin-project/feat/parallel-block-val
run block validation for tipsets in parallel
This commit is contained in:
commit
7b2241f051
@ -466,16 +466,27 @@ func (syncer *Syncer) ValidateTipSet(ctx context.Context, fts *store.FullTipSet)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var futures []async.ErrorFuture
|
||||||
for _, b := range fts.Blocks {
|
for _, b := range fts.Blocks {
|
||||||
if err := syncer.ValidateBlock(ctx, b); err != nil {
|
b := b // rebind to a scoped variable
|
||||||
if isPermanent(err) {
|
|
||||||
syncer.bad.Add(b.Cid(), err.Error())
|
|
||||||
}
|
|
||||||
return xerrors.Errorf("validating block %s: %w", b.Cid(), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := syncer.sm.ChainStore().AddToTipSetTracker(b.Header); err != nil {
|
futures = append(futures, async.Err(func() error {
|
||||||
return xerrors.Errorf("failed to add validated header to tipset tracker: %w", err)
|
if err := syncer.ValidateBlock(ctx, b); err != nil {
|
||||||
|
if isPermanent(err) {
|
||||||
|
syncer.bad.Add(b.Cid(), err.Error())
|
||||||
|
}
|
||||||
|
return xerrors.Errorf("validating block %s: %w", b.Cid(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := syncer.sm.ChainStore().AddToTipSetTracker(b.Header); err != nil {
|
||||||
|
return xerrors.Errorf("failed to add validated header to tipset tracker: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
for _, f := range futures {
|
||||||
|
if err := f.AwaitContext(ctx); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user