From e68b242243e06004f31e20b9a65f8a896543821f Mon Sep 17 00:00:00 2001 From: Svarog Date: Tue, 3 Dec 2019 14:18:32 +0200 Subject: [PATCH] [NOD-489] Don't skip notification about transactions for orphan/non-current blocks (#511) --- netsync/manager.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/netsync/manager.go b/netsync/manager.go index da366a010..eb912f20a 100644 --- a/netsync/manager.go +++ b/netsync/manager.go @@ -7,12 +7,13 @@ package netsync import ( "container/list" "fmt" - "github.com/pkg/errors" "net" "sync" "sync/atomic" "time" + "github.com/pkg/errors" + "github.com/daglabs/btcd/blockdag" "github.com/daglabs/btcd/dagconfig" "github.com/daglabs/btcd/database" @@ -1290,16 +1291,13 @@ func (sm *SyncManager) handleBlockDAGNotification(notification *blockdag.Notific } }) - // Don't relay if we are not current or the block was just now unorphaned. - // Other peers that are current should already know about it - if !sm.current() || data.WasUnorphaned { - return + // Relay if we are current and the block was not just now unorphaned. + // Otherwise peers that are current should already know about it + if sm.current() && !data.WasUnorphaned { + iv := wire.NewInvVect(wire.InvTypeBlock, block.Hash()) + sm.peerNotifier.RelayInventory(iv, block.MsgBlock().Header) } - // Generate the inventory vector and relay it. - iv := wire.NewInvVect(wire.InvTypeBlock, block.Hash()) - sm.peerNotifier.RelayInventory(iv, block.MsgBlock().Header) - for msg := range ch { sm.peerNotifier.TransactionConfirmed(msg.Tx) sm.peerNotifier.AnnounceNewTransactions(msg.AcceptedTxs)