mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
chainntnfs/btcdnotify: fix dropped block epoch notification bug
This commit a bug introduced in the chain notifier while we were limiting the usage of mutexes within the package. In a prior commit a default case was introduced in the select statement in order to avoid the possibility of the main goroutine blocking when dispatching block epoch notification. In order to avoid this potentially disastrous bug, we now instead launch a new goroutine for each client to ensure that all notifications are reliably dispatched.
This commit is contained in:
parent
d2b4f143b9
commit
608b9d96d1
@ -476,14 +476,13 @@ func (b *BtcdNotifier) notifyBlockEpochs(newHeight int32, newSha *chainhash.Hash
|
||||
}
|
||||
|
||||
for _, epochChan := range b.blockEpochClients {
|
||||
// Attempt a non-blocking send. If the buffered channel is
|
||||
// full, then we no-op and move onto the next client.
|
||||
select {
|
||||
case epochChan <- epoch:
|
||||
case <-b.quit:
|
||||
return
|
||||
default:
|
||||
}
|
||||
go func(ntfnChan chan *chainntnfs.BlockEpoch) {
|
||||
select {
|
||||
case ntfnChan <- epoch:
|
||||
case <-b.quit:
|
||||
return
|
||||
}
|
||||
}(epochChan)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user