feat: chainstore: exit early in MaybeTakeHeavierTipset

This commit is contained in:
Aayush 2023-05-05 11:31:39 -04:00
parent 9ae42929d7
commit 596b01fba2
2 changed files with 6 additions and 1 deletions

View File

@ -125,7 +125,7 @@ func (o *observer) listenHeadChangesOnce(ctx context.Context) error {
for changes := range notifs { for changes := range notifs {
if err := o.applyChanges(ctx, changes); err != nil { if err := o.applyChanges(ctx, changes); err != nil {
return err return xerrors.Errorf("failed to apply a change notification: %w", err)
} }
} }

View File

@ -425,6 +425,11 @@ func (cs *ChainStore) MaybeTakeHeavierTipSet(ctx context.Context, ts *types.TipS
} }
defer cs.heaviestLk.Unlock() defer cs.heaviestLk.Unlock()
if ts.Equals(cs.heaviest) {
return nil
}
w, err := cs.weight(ctx, cs.StateBlockstore(), ts) w, err := cs.weight(ctx, cs.StateBlockstore(), ts)
if err != nil { if err != nil {
return err return err