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.
This commit is contained in:
David Hill 2016-08-09 14:59:46 -04:00 committed by Alex Yocom-Piatt
parent 61dfe146a9
commit 696dcddb23

View File

@ -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)