contractcourt: add Launch method to anchor/breach resolver
We will use this and its following commits to break the original `Resolve` methods into two parts - the first part is moved to a new method `Launch`, which handles sending a sweep request to the sweeper. The second part remains in `Resolve`, which is mainly waiting for a spending tx. Breach resolver currently doesn't do anything in its `Launch` since the sweeping of justice outputs are not handled by the sweeper yet.
This commit is contained in:
3 files changed
+153
-87
No files matched your search
@@ -47,6 +47,8 @@ func (b *breachResolver) ResolverKey() []byte {
|
||||
// Resolve queries the BreachArbitrator to see if the justice transaction has
|
||||
// been broadcast.
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
//
|
||||
// TODO(yy): let sweeper handle the breach inputs.
|
||||
func (b *breachResolver) Resolve() (ContractResolver, error) {
|
||||
if !b.subscribed {
|
||||
@@ -83,6 +85,7 @@ func (b *breachResolver) Resolve() (ContractResolver, error) {
|
||||
|
||||
// Stop signals the breachResolver to stop.
|
||||
func (b *breachResolver) Stop() {
|
||||
b.log.Debugf("stopping...")
|
||||
close(b.quit)
|
||||
}
|
||||
|
||||
@@ -123,3 +126,21 @@ func newBreachResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
||||
// A compile time assertion to ensure breachResolver meets the ContractResolver
|
||||
// interface.
|
||||
var _ ContractResolver = (*breachResolver)(nil)
|
||||
|
||||
// Launch offers the breach outputs to the sweeper - currently it's a NOOP as
|
||||
// the outputs here are not offered to the sweeper.
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
//
|
||||
// TODO(yy): implement it once the outputs are offered to the sweeper.
|
||||
func (b *breachResolver) Launch() error {
|
||||
if b.launched {
|
||||
b.log.Tracef("already launched")
|
||||
return nil
|
||||
}
|
||||
|
||||
b.log.Debugf("launching resolver...")
|
||||
b.launched = true
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user