From 69e47a4e25e6a658b195805aa665be16f9ed704a Mon Sep 17 00:00:00 2001 From: maebeam Date: Fri, 5 Nov 2021 09:55:28 -0700 Subject: [PATCH] Always add accounts to inactive reconciler queue (#350) --- reconciler/reconciler.go | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/reconciler/reconciler.go b/reconciler/reconciler.go index c280f6ce9..a90fcdc3a 100644 --- a/reconciler/reconciler.go +++ b/reconciler/reconciler.go @@ -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 { @@ -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)