From: Yongfeng LI Date: Fri, 9 Mar 2018 06:09:02 +0000 (+0800) Subject: fix import private key (#405) X-Git-Tag: v1.0.5~299 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f2c69012610037836f796867a29cc32a87a23935;p=bytom%2Fbytom.git fix import private key (#405) --- diff --git a/blockchain/wallet/wallet.go b/blockchain/wallet/wallet.go index 9d8e3b6e..39e34298 100755 --- a/blockchain/wallet/wallet.go +++ b/blockchain/wallet/wallet.go @@ -318,8 +318,7 @@ func (w *Wallet) createProgram(account *account.Account, XPub *pseudohsm.XPub, i func (w *Wallet) rescanBlocks() { select { - case <-w.rescanProgress: - w.rescanProgress <- struct{}{} + case w.rescanProgress <- struct{}{}: default: return } @@ -356,16 +355,15 @@ func (w *Wallet) GetRescanStatus() ([]KeyInfo, error) { return keysInfo, nil } +//checkRescanStatus mark private key import process `Complete` if rescan finished func checkRescanStatus(w *Wallet) { - if !w.ImportPrivKey { + if !w.ImportPrivKey || w.status.WorkHeight < w.status.BestHeight { return } - if w.status.WorkHeight >= w.status.BestHeight { - w.ImportPrivKey = false - for i := range w.keysInfo { - w.keysInfo[i].Complete = true - } - } + w.ImportPrivKey = false + for _, keyInfo := range w.keysInfo { + keyInfo.Complete = true + } w.commitkeysInfo() }