Skip to content

Commit

Permalink
Always add accounts to inactive reconciler queue (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
maebeam authored Nov 5, 2021
1 parent 8ea678a commit 69e47a4
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,26 @@ func (r *Reconciler) queueChanges(
}

for _, change := range balanceChanges {
// Add all seen accounts to inactive reconciler queue.
//
// Note: accounts are only added if they have not been seen before.
//
// We always add accounts to the inactive reconciler queue even if we're
// below the high water mark. Once we have synced all the blocks the inactive
// queue will recognize we are at the tip and will begin reconciliation of all
// accounts.
acctCurrency := &types.AccountCurrency{
Account: change.Account,
Currency: change.Currency,
}

r.inactiveQueueMutex.Lock(true)
err := r.inactiveAccountQueue(false, acctCurrency, block, true)
r.inactiveQueueMutex.Unlock()
if err != nil {
return err
}

// All changes will have the same block. Continue
// if we are too far behind to start reconciling.
if block.Index < r.highWaterMark {
Expand All @@ -218,21 +238,6 @@ func (r *Reconciler) queueChanges(
continue
}

// Add all seen accounts to inactive reconciler queue.
//
// Note: accounts are only added if they have not been seen before.
acctCurrency := &types.AccountCurrency{
Account: change.Account,
Currency: change.Currency,
}

r.inactiveQueueMutex.Lock(true)
err := r.inactiveAccountQueue(false, acctCurrency, block, true)
r.inactiveQueueMutex.Unlock()
if err != nil {
return err
}

// Add change to queueMap before enqueuing to ensure
// there is no possible race.
key := types.Hash(acctCurrency)
Expand Down

0 comments on commit 69e47a4

Please sign in to comment.