chainntnfs/neutrino: start concurrent queues prior to connection

Similar to what was done for btcd, just to make sure we won't be blocked
on any incoming notifications, start the queues first thing during
startup.
This commit is contained in:
Johan T. Halseth 2019-09-12 14:36:38 +02:00
parent 6b6beb4d7d
commit d195acc632
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -116,12 +116,20 @@ func (n *NeutrinoNotifier) Start() error {
return nil
}
// Start our concurrent queues before starting the rescan, to ensure
// onFilteredBlockConnected and onRelavantTx callbacks won't be
// blocked.
n.chainUpdates.Start()
n.txUpdates.Start()
// First, we'll obtain the latest block height of the p2p node. We'll
// start the auto-rescan from this point. Once a caller actually wishes
// to register a chain view, the rescan state will be rewound
// accordingly.
startingPoint, err := n.p2pNode.BestBlock()
if err != nil {
n.txUpdates.Stop()
n.chainUpdates.Stop()
return err
}
n.bestBlock.Hash = &startingPoint.Hash
@ -160,9 +168,6 @@ func (n *NeutrinoNotifier) Start() error {
)
n.rescanErr = n.chainView.Start()
n.chainUpdates.Start()
n.txUpdates.Start()
n.wg.Add(1)
go n.notificationDispatcher()