Skip to content

Commit

Permalink
feat: chainstore: exit early in MaybeTakeHeavierTipset
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed May 5, 2023
1 parent 9ae4292 commit 8549c16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chain/events/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (o *observer) listenHeadChangesOnce(ctx context.Context) error {

for changes := range notifs {
if err := o.applyChanges(ctx, changes); err != nil {
return err
return xerrors.Errorf("failed to apply a change notification: %w", err)
}
}

Expand Down
5 changes: 5 additions & 0 deletions chain/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ func (cs *ChainStore) MaybeTakeHeavierTipSet(ctx context.Context, ts *types.TipS
}

defer cs.heaviestLk.Unlock()

if ts.Equals(cs.heaviest) {
return nil
}

w, err := cs.weight(ctx, cs.StateBlockstore(), ts)
if err != nil {
return err
Expand Down

0 comments on commit 8549c16

Please sign in to comment.