9c18c3d9a4
In this commit, we fix a lingering bug related to the way that we deliver block epoch notifications to end users. Before this commit, we would launch a new goroutine for *each block*. This was done in order to ensure that the notification dispatch wouldn’t block the main goroutine that was dispatching the notifications. This method archived the goal, but had a nasty side effect that the goroutines could be re-ordered during scheduling, meaning that in the case of fast successive blocks, then notifications would be delivered out of order. Receiving out of order notifications is either disallowed, or can cause sub-systems that rely on these notifications to get into weird states. In order to fix this issue, we’ll no longer launch a new goroutine to deliver each notification to an awaiting client. Instead, each client will now gain a concurrent in-order queue for notification delivery. Due to the internal design of chainntnfs.ConcurrentQueue, the caller should never block, yet the receivers will receive notifications in order. This change solves the re-ordering issue and also minimizes the number of goroutines that we’ll create in order to deliver block epoch notifications. |
||
---|---|---|
.. | ||
bitcoindnotify | ||
btcdnotify | ||
neutrinonotify | ||
interface_test.go | ||
interface.go | ||
log.go | ||
queue_test.go | ||
queue.go | ||
README.md | ||
txconfnotifier_test.go | ||
txconfnotifier.go |
chainntnfs
The chainntnfs package implements a set of interfaces which allow callers to receive notifications in response to specific on-chain events. The set of notifications available include:
- Notifications for each new block connected to the current best chain.
- Notifications once a
txid
has reached a specified number of confirmations. - Notifications once a target outpoint (
txid:index
) has been spent.
These notifications are used within lnd
in order to properly handle the
workflows for: channel funding, cooperative channel closures, forced channel
closures, channel contract breaches, sweeping time-locked outputs, and finally
pruning the channel graph.
This package is intentionally general enough to be applicable outside the
specific use cases within lnd
outlined above. The current sole concrete
implementation of the ChainNotifier
interface depends on btcd
.
Installation and Updating
$ go get -u github.com/lightningnetwork/lnd/chainntnfs