Add lotus shed util to validate a tipset

This commit is contained in:
Aayush Rajasekaran
2020-09-30 01:29:04 -04:00
parent 6025bceaa1
commit a4e7117429
6 changed files with 109 additions and 0 deletions
+26
View File
@@ -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
}