From 696dcddb23d4b81a5707f12ea05dfbe7a1bca783 Mon Sep 17 00:00:00 2001 From: David Hill Date: Tue, 9 Aug 2016 14:59:46 -0400 Subject: [PATCH] Return from syncMiningStateAfterSync if peer disconnected. (#310) Before this fix, if a peer disconnected before the chain was marked current, its goroutine and memory would hang around until the chain was marked current. This would cause out-of-memory errors. This should also speed up blockchain processing since there are no longer many goroutines calling IsCurrent every 3 seconds. --- blockmanager.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blockmanager.go b/blockmanager.go index d58921a8..8270f25f 100644 --- a/blockmanager.go +++ b/blockmanager.go @@ -784,6 +784,9 @@ func (b *blockManager) syncMiningStateAfterSync(sp *serverPeer) { for { select { case <-ticker.C: + if !sp.Connected() { + return + } if b.IsCurrent() { msg := wire.NewMsgGetMiningState() sp.QueueMessage(msg, nil)