From 55882173a20a1ef4ece6763e81f7a702538ca827 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 15 Jan 2014 12:26:55 -0500 Subject: [PATCH] Spawn goroutine to rescan on imported privkeys. Fixes #34. --- account.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/account.go b/account.go index 7f70659..cef60e4 100644 --- a/account.go +++ b/account.go @@ -390,12 +390,16 @@ func (a *Account) ImportPrivKey(wif string, rescan bool) error { } if rescan { - addrs := map[string]struct{}{ - addr: struct{}{}, - } + // Do not wait for rescan to finish before returning to the + // caller. + go func() { + addrs := map[string]struct{}{ + addr: struct{}{}, + } - Rescan(CurrentRPCConn(), bs.Height, addrs) - a.writeDirtyToDisk() + Rescan(CurrentRPCConn(), bs.Height, addrs) + a.writeDirtyToDisk() + }() } return nil }