From 891fb20622556673628e160e23e08dbd61bd1f3a Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 5 Mar 2018 16:18:14 +0100 Subject: [PATCH] neutrinonotify: use epochqueue to notify block epochs --- chainntnfs/neutrinonotify/neutrino.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index aefd02b1..e347e6d8 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -528,24 +528,14 @@ func (n *NeutrinoNotifier) notifyBlockEpochs(newHeight int32, newSha *chainhash. } for _, epochClient := range n.blockEpochClients { - n.wg.Add(1) - epochClient.wg.Add(1) - go func(ntfnChan chan *chainntnfs.BlockEpoch, cancelChan chan struct{}, - clientWg *sync.WaitGroup) { + select { - defer clientWg.Done() - defer n.wg.Done() + case epochClient.epochQueue.ChanIn() <- epoch: - select { - case ntfnChan <- epoch: + case <-epochClient.cancelChan: - case <-cancelChan: - return - - case <-n.quit: - return - } - }(epochClient.epochChan, epochClient.cancelChan, &epochClient.wg) + case <-n.quit: + } } }