Add lotus shed util to validate a tipset
This commit is contained in:
@@ -126,3 +126,29 @@ func (a *SyncAPI) SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error
|
||||
|
||||
return reason, nil
|
||||
}
|
||||
|
||||
func (a *SyncAPI) SyncValidateTipset(ctx context.Context, tsk types.TipSetKey) (bool, error) {
|
||||
ts, err := a.Syncer.ChainStore().LoadTipSet(tsk)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
fts, err := a.Syncer.ChainStore().TryFillTipSet(ts)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, blk := range tsk.Cids() {
|
||||
err = a.Syncer.ChainStore().UnmarkBlockAsValidated(ctx, blk)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
err = a.Syncer.ValidateTipSet(ctx, fts)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user