chainntnfs/neutrinonotify: make chainUpdates a buffered chan

ConcurrentQueue has internal structures so if a filterUpdate exists
in it, the idea of draining the queue may not work reliably. The
update may exist in the ConcurrentQueue but may not be available via
ChanOut() when we're ready to drain the ConcurrentQueue. Fix this by
using a regular buffered chan, which will either have the update or
not have the update. Its size is set to 100 as our tests may generate
quite a bit of updates.
This commit is contained in:
eugene committed 2021-08-27 14:12:01 -04:00
1 parent 86f28cdc1d
commit b7de0eae93
2 files changed
+12 -14

No files matched your search

+2 -3
View File
@@ -63,7 +63,6 @@ func (n *NeutrinoNotifier) UnsafeStart(bestHeight int32,
)
n.rescanErr = n.chainView.Start()
n.chainUpdates.Start()
n.txUpdates.Start()
if generateBlocks != nil {
@@ -80,8 +79,8 @@ func (n *NeutrinoNotifier) UnsafeStart(bestHeight int32,
loop:
for {
select {
case ntfn := <-n.chainUpdates.ChanOut():
lastReceivedNtfn := ntfn.(*filteredBlock)
case ntfn := <-n.chainUpdates:
lastReceivedNtfn := ntfn
if lastReceivedNtfn.height >= uint32(syncHeight) {
break loop
}