Merge pull request #604 from wpaulino/scan-chain-bug-fix

wallet: ensure bestHeight is updated before isCurrent check
This commit is contained in:
Olaoluwa Osuntokun 2019-03-12 20:26:08 -07:00 committed by GitHub
commit acf3b04b02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -518,15 +518,20 @@ func (w *Wallet) scanChain(startHeight int32,
return err return err
} }
// If we've reached our best height and we're not current, we'll // If we've reached our best height, we'll wait for blocks at
// wait for blocks at tip to ensure we go through all existent // tip to ensure we go through all existent blocks in the chain.
// blocks. // We'll update our bestHeight before checking if we're current
for height == bestHeight && !isCurrent(bestHeight) { // with the chain to ensure we process any additional blocks
// that came in while we were scanning from our starting point.
for height == bestHeight {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
_, bestHeight, err = chainClient.GetBestBlock() _, bestHeight, err = chainClient.GetBestBlock()
if err != nil { if err != nil {
return err return err
} }
if isCurrent(bestHeight) {
break
}
} }
} }