contractcourt: add new SubscribeChannelEvents method to ChainArbitrator
In this commit, we add a new method to allow external sub-systems to gain an intent to receive notifications once an on-chain event happens. This will be used in place of the old channel signals directly on the channel state machine object in a series of follow up commits.
This commit is contained in:
parent
754d1c1c38
commit
b5ae0855d2
@ -615,13 +615,27 @@ func (c *ChainArbitrator) ManuallyResolveChannel(chanPoint wire.OutPoint) error
|
|||||||
return chainWatcher.Start()
|
return chainWatcher.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeChannelSignals...
|
// SubscribeChannelEvents returns a new active subscription for the set of
|
||||||
func (c *ChainArbitrator) SubscribeChannelSignals() error {
|
// possible on-chain events for a particular channel. The struct can be used by
|
||||||
// TODO(roasbeef): gives signals of spends, breaches, etc
|
// callers to be notified whenever an event that changes the state of the
|
||||||
// * breach arg grabs initially
|
// channel on-chain occurs.
|
||||||
// * create new db method for *just* getting the outpoints for em all?
|
//
|
||||||
|
// TODO(roasbeef): can be used later to provide RPC hook for all channel
|
||||||
|
// lifetimes
|
||||||
|
func (c *ChainArbitrator) SubscribeChannelEvents(
|
||||||
|
chanPoint wire.OutPoint) (*ChainEventSubscription, error) {
|
||||||
|
|
||||||
return nil
|
// First, we'll attempt to look up the active watcher for this channel.
|
||||||
|
// If we can't find it, then we'll return an error back to the caller.
|
||||||
|
watcher, ok := c.activeWatchers[chanPoint]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unable to find watcher for: %v",
|
||||||
|
chanPoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
// With the watcher located, we'll request for it to create a new chain
|
||||||
|
// event subscription client.
|
||||||
|
return watcher.SubscribeChannelEvents(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): arbitration reports
|
// TODO(roasbeef): arbitration reports
|
||||||
|
Loading…
Reference in New Issue
Block a user