Commit Graph

61 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
a3319bb21a
chainntnfs: add the ability to cancel spend+epoch notifications
When iterating with the ChainNotifier, it currently isn’t possible to
cancel a non-dispatched yet active notificaiton intent. As a result,
this can be rather wasteful in many parts of lnd which my repeatedly
create a new spend notification depending on if/when a peer is
connected or not.

In order to fix this, we add a new `Cancel func()` field to both the
`BlockEpochEvent` and `SpendEvent` structs. This new closure attribute
allows the caller to cancel the yet-to-be-dispathed event, allowing the
ChainNotifier to free up resources.
2017-02-21 01:42:50 -08:00
Olaoluwa Osuntokun
384fe61e73
multi: fix go vet warnings throughout code base 2017-02-16 19:33:19 +08:00
Olaoluwa Osuntokun
5affed38fc
multi: update btcsuite API's to latest upstream changes
This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
2017-01-05 13:56:34 -08:00
Olaoluwa Osuntokun
00b0c273da
chainntnfs: ConfirmationEvent now returns details of tx confirmation
This commit modifies the ChainNotifier interface, specifically the
ConfirmationEvent struct to now return additional details concerning
the exact location in the chain that the transaction was confirmed at.

This information will be very useful within the new routing package, as
within the network, channels are identified via their channel-ID which
is a compact encoding of: blockHeight | txIndex | outputIndex
2016-12-27 16:43:56 -08:00
Olaoluwa Osuntokun
1e3635b5aa
chainntnfs: properly account for partial historical confirmation dispatch
This commit modifies the recently added logic to the ChainNotifier to:
  1. Fix the off-by-one confirmation error that was missed due a flaky
test
  2. Ensure that partial historical confirmations are properly handled.

The partial hostile confirmation case arises when a transaction already
a non-zero number of confirmations when the notification is registered,
but less than what would trigger the confirmation notification. To fix
this, transaction which have a partial number of confirmation are now
properly inserted into the confHeap, skipping first first phase for
notifications.
2016-12-08 16:16:29 -08:00
bryanvu
909c3f8df9 chainntfs: add checks for previously confirmed transactions and spends
Without these checks, “zombie” notification requests that would never
be dispatched could be registered. This would occur if notification
requests were made for events (transaction confirmation and output
spent) that had already been recorded on the blockchain.
2016-12-08 12:28:15 -08:00
Olaoluwa Osuntokun
7b016fef0a
chainntfns: extend testSpendNotification to test for multi-client dispatch 2016-11-27 19:18:24 -08:00
Olaoluwa Osuntokun
112ad616f6
chainntnfs: remove unnecessary print statement in tests 2016-09-13 15:33:32 -07:00
Olaoluwa Osuntokun
0873c4da76
chainntnfs: add multi-client txid support for confirmation notifications
This commit adds multi-client support for confirmation notification of
the same transaction. Within the daemon there might be scenarios where
multiple goroutines are waiting for the same transaction to be
confirmed in order to properly fulfill their tasks. Previously if
multiple clients were registered for the same txid confirmation
notification, then only the client who registered last would receive
the notification.
2016-09-12 19:07:16 -07:00
Olaoluwa Osuntokun
e72c52288d
chainntfns: implement RegisterBlockEpochNtfn for BtcdNotifier, add tests 2016-09-12 19:07:08 -07:00
Olaoluwa Osuntokun
4d1a1d2799
chainntnfs: add cross interface implementation tests
This commit refactors the existing chainntnfns package in order to
allow more easily allow integration into the main system, by allowing
one to gain access to a set of end-to-end tests for a particular
ChainNotifier implementation.

In order to achieve this, the existing set of tests for the only
concrete implementation (`BtcdNoitifer`) have been refactored to test
against all “registered” notifier interfaces registered. This is
achieved by creating the concept of a “driver” for each concrete
`ChainNotifer` implementation. Once a the package of a particular
driver is imported, solely for the side effects, the init() method
automatically registers the driver.

Additionally, the documentation in various areas of the package have
been cleaned up a bit.
2016-09-01 19:13:10 -07:00