Skip to content

Commit 1611135

Browse files
committed
multi: add cancel swap function to execute config
1 parent 4040bb3 commit 1611135

6 files changed

+11
-0
lines changed

client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func NewClient(dbDir string, cfg *ClientConfig) (*Client, func(), error) {
142142
sweeper: sweeper,
143143
createExpiryTimer: config.CreateExpiryTimer,
144144
loopOutMaxParts: cfg.LoopOutMaxParts,
145+
cancelSwap: swapServerClient.CancelLoopOutSwap,
145146
})
146147

147148
client := &Client{

executor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type executorConfig struct {
2525
createExpiryTimer func(expiry time.Duration) <-chan time.Time
2626

2727
loopOutMaxParts uint32
28+
29+
cancelSwap func(ctx context.Context, details *outCancelDetails) error
2830
}
2931

3032
// executor is responsible for executing swaps.
@@ -144,6 +146,7 @@ func (s *executor) run(mainCtx context.Context,
144146
blockEpochChan: queue.ChanOut(),
145147
timerFactory: s.executorConfig.createExpiryTimer,
146148
loopOutMaxParts: s.executorConfig.loopOutMaxParts,
149+
cancelSwap: s.executorConfig.cancelSwap,
147150
}, height)
148151

149152
select {

loopin_testcontext_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func newLoopInTestContext(t *testing.T) *loopInTestContext {
3939
sweeper: &sweeper,
4040
blockEpochChan: blockEpochChan,
4141
timerFactory: timerFactory,
42+
cancelSwap: server.CancelLoopOutSwap,
4243
}
4344

4445
return &loopInTestContext{

loopout.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type executeConfig struct {
7575
blockEpochChan <-chan interface{}
7676
timerFactory func(d time.Duration) <-chan time.Time
7777
loopOutMaxParts uint32
78+
cancelSwap func(context.Context, *outCancelDetails) error
7879
}
7980

8081
// loopOutInitResult contains information about a just-initiated loop out swap.

loopout_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func TestLoopOutPaymentParameters(t *testing.T) {
7373
blockEpochChan: blockEpochChan,
7474
timerFactory: timerFactory,
7575
loopOutMaxParts: maxParts,
76+
cancelSwap: server.CancelLoopOutSwap,
7677
}, height)
7778
if err != nil {
7879
log.Error(err)
@@ -173,6 +174,7 @@ func TestLateHtlcPublish(t *testing.T) {
173174
sweeper: sweeper,
174175
blockEpochChan: blockEpochChan,
175176
timerFactory: timerFactory,
177+
cancelSwap: server.CancelLoopOutSwap,
176178
}, height)
177179
if err != nil {
178180
log.Error(err)
@@ -267,6 +269,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
267269
blockEpochChan: blockEpochChan,
268270
timerFactory: timerFactory,
269271
sweeper: sweeper,
272+
cancelSwap: server.CancelLoopOutSwap,
270273
}, ctx.Lnd.Height)
271274
if err != nil {
272275
log.Error(err)
@@ -461,6 +464,7 @@ func TestPreimagePush(t *testing.T) {
461464
blockEpochChan: blockEpochChan,
462465
timerFactory: timerFactory,
463466
sweeper: sweeper,
467+
cancelSwap: server.CancelLoopOutSwap,
464468
}, ctx.Lnd.Height)
465469
if err != nil {
466470
log.Error(err)

testcontext_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func newSwapClient(config *clientConfig) *Client {
5252
store: config.Store,
5353
sweeper: sweeper,
5454
createExpiryTimer: config.CreateExpiryTimer,
55+
cancelSwap: config.Server.CancelLoopOutSwap,
5556
})
5657

5758
return &Client{

0 commit comments

Comments
 (0)