From 16111352a8238ca12364c173773806edefe4a696 Mon Sep 17 00:00:00 2001 From: carla Date: Mon, 24 May 2021 08:40:14 +0200 Subject: [PATCH] multi: add cancel swap function to execute config --- client.go | 1 + executor.go | 3 +++ loopin_testcontext_test.go | 1 + loopout.go | 1 + loopout_test.go | 4 ++++ testcontext_test.go | 1 + 6 files changed, 11 insertions(+) diff --git a/client.go b/client.go index 94c3646..00edc4a 100644 --- a/client.go +++ b/client.go @@ -142,6 +142,7 @@ func NewClient(dbDir string, cfg *ClientConfig) (*Client, func(), error) { sweeper: sweeper, createExpiryTimer: config.CreateExpiryTimer, loopOutMaxParts: cfg.LoopOutMaxParts, + cancelSwap: swapServerClient.CancelLoopOutSwap, }) client := &Client{ diff --git a/executor.go b/executor.go index 8008c09..25f9f9d 100644 --- a/executor.go +++ b/executor.go @@ -25,6 +25,8 @@ type executorConfig struct { createExpiryTimer func(expiry time.Duration) <-chan time.Time loopOutMaxParts uint32 + + cancelSwap func(ctx context.Context, details *outCancelDetails) error } // executor is responsible for executing swaps. @@ -144,6 +146,7 @@ func (s *executor) run(mainCtx context.Context, blockEpochChan: queue.ChanOut(), timerFactory: s.executorConfig.createExpiryTimer, loopOutMaxParts: s.executorConfig.loopOutMaxParts, + cancelSwap: s.executorConfig.cancelSwap, }, height) select { diff --git a/loopin_testcontext_test.go b/loopin_testcontext_test.go index 3ac682e..1af542d 100644 --- a/loopin_testcontext_test.go +++ b/loopin_testcontext_test.go @@ -39,6 +39,7 @@ func newLoopInTestContext(t *testing.T) *loopInTestContext { sweeper: &sweeper, blockEpochChan: blockEpochChan, timerFactory: timerFactory, + cancelSwap: server.CancelLoopOutSwap, } return &loopInTestContext{ diff --git a/loopout.go b/loopout.go index 15b480c..8a20349 100644 --- a/loopout.go +++ b/loopout.go @@ -75,6 +75,7 @@ type executeConfig struct { blockEpochChan <-chan interface{} timerFactory func(d time.Duration) <-chan time.Time loopOutMaxParts uint32 + cancelSwap func(context.Context, *outCancelDetails) error } // loopOutInitResult contains information about a just-initiated loop out swap. diff --git a/loopout_test.go b/loopout_test.go index 1efb9d6..c4eeca9 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -73,6 +73,7 @@ func TestLoopOutPaymentParameters(t *testing.T) { blockEpochChan: blockEpochChan, timerFactory: timerFactory, loopOutMaxParts: maxParts, + cancelSwap: server.CancelLoopOutSwap, }, height) if err != nil { log.Error(err) @@ -173,6 +174,7 @@ func TestLateHtlcPublish(t *testing.T) { sweeper: sweeper, blockEpochChan: blockEpochChan, timerFactory: timerFactory, + cancelSwap: server.CancelLoopOutSwap, }, height) if err != nil { log.Error(err) @@ -267,6 +269,7 @@ func TestCustomSweepConfTarget(t *testing.T) { blockEpochChan: blockEpochChan, timerFactory: timerFactory, sweeper: sweeper, + cancelSwap: server.CancelLoopOutSwap, }, ctx.Lnd.Height) if err != nil { log.Error(err) @@ -461,6 +464,7 @@ func TestPreimagePush(t *testing.T) { blockEpochChan: blockEpochChan, timerFactory: timerFactory, sweeper: sweeper, + cancelSwap: server.CancelLoopOutSwap, }, ctx.Lnd.Height) if err != nil { log.Error(err) diff --git a/testcontext_test.go b/testcontext_test.go index 4f3caf8..5a71d97 100644 --- a/testcontext_test.go +++ b/testcontext_test.go @@ -52,6 +52,7 @@ func newSwapClient(config *clientConfig) *Client { store: config.Store, sweeper: sweeper, createExpiryTimer: config.CreateExpiryTimer, + cancelSwap: config.Server.CancelLoopOutSwap, }) return &Client{