Commit Graph

104 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
723bfb0eac
contractcourt: channel arbitrators now exit on co-op close of the channel 2018-01-22 19:19:52 -08:00
Olaoluwa Osuntokun
754d1c1c38
contractcourt: when handling a remote force close, use their view of the HTLC's 2018-01-22 19:19:49 -08:00
Olaoluwa Osuntokun
63f7bf4e65
contractcourt: integrate notifications of the chainWatcher with each channel arb
In this commit, we modify the construction of the channel arbitrator to
accept a pointer to an event stream from the chain watcher that’s been
assigned to that channel. As a result, we no longer need a fresh
unilateral close signal, as the one we get from the chain watcher will
*always* be up to date.

For each active channel, we’ll now create a chainWatcher instance that
will be around until the channel is fully closed on chain.
2018-01-22 19:19:48 -08:00
Olaoluwa Osuntokun
d64ffcb6c8
contractcourt: add new ChannelArbitrator struct
In this commit, we add the primary struct of the package with a full
implementation. The duty of the ChannelArbitrator is to watch the set
of active contracts on a comment transaction and act accordingly if any
of their redemption criteria have been met. Potential criteria include:
an HTLC about to time out, and HTLC about to time out that we know the
preiamge to, or the remote party going to chain (forcing us to resolve
all pending contracts on chain).

The primary goroutine of this struct implements a persistent state
machine in order to ensure that mid contract resolution, we’re able to
properly survive restarts without losing our place, or forgetting about
a pending contract.

A ChannelArbitrator will stay alive until all contracts have been fully
resolved. This means that outside sub-systems no longer need to worry
about remembering to mark a channel as fully resolved, as it’s the job
of the ChannelArbitrator to do this task.
2018-01-22 19:19:34 -08:00