Skip to content

Commit

Permalink
Cleanup bestLive balance
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Oct 19, 2020
1 parent 5e509cf commit 40aacf0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,27 @@ func (r *Reconciler) bestLiveBalance(
)

// Don't check canonical block if context
// is canceled (to make sure we don't erroneously
// return ErrBlockGone).
if errors.Is(err, context.Canceled) {
// is canceled or lookupBlock is nil (to
// make sure we don't erroneously return ErrBlockGone).
if errors.Is(err, context.Canceled) || lookupBlock == nil {
return nil, nil, liveFetchErr
}

// If there is a reorg, there is a chance that balance
// lookup can fail if we try to query an orphaned block.
// If this is the case, we continue reconciling.
canonical, canonicalErr := r.helper.CanonicalBlock(ctx, block)
if errors.Is(canonicalErr, context.Canceled) {
return nil, nil, liveFetchErr
canonical, canonicalErr := r.helper.CanonicalBlock(ctx, lookupBlock)
if err != nil {
return nil, nil, fmt.Errorf(
"%w: unable to check canonical block %s",
canonicalErr,
types.PrintStruct(lookupBlock),
)
}
if canonicalErr != nil || !canonical {

// Return ErrBlockGone if lookupBlock is not considered
// canonical.
if !canonical {
return nil, nil, ErrBlockGone
}

Expand Down

0 comments on commit 40aacf0

Please sign in to comment.