Browse Source

multi: add cancel swap function to execute config

pull/378/head
carla 4 months ago
parent
commit
16111352a8
No known key found for this signature in database GPG Key ID: 4CA7FE54A6213C91
6 changed files with 11 additions and 0 deletions
  1. +1
    -0
      client.go
  2. +3
    -0
      executor.go
  3. +1
    -0
      loopin_testcontext_test.go
  4. +1
    -0
      loopout.go
  5. +4
    -0
      loopout_test.go
  6. +1
    -0
      testcontext_test.go

+ 1
- 0
client.go View File

@ -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{

+ 3
- 0
executor.go View File

@ -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 {

+ 1
- 0
loopin_testcontext_test.go View File

@ -39,6 +39,7 @@ func newLoopInTestContext(t *testing.T) *loopInTestContext {
sweeper: &sweeper,
blockEpochChan: blockEpochChan,
timerFactory: timerFactory,
cancelSwap: server.CancelLoopOutSwap,
}
return &loopInTestContext{

+ 1
- 0
loopout.go View File

@ -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.

+ 4
- 0
loopout_test.go View File

@ -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)

+ 1
- 0
testcontext_test.go View File

@ -52,6 +52,7 @@ func newSwapClient(config *clientConfig) *Client {
store: config.Store,
sweeper: sweeper,
createExpiryTimer: config.CreateExpiryTimer,
cancelSwap: config.Server.CancelLoopOutSwap,
})
return &Client{

Loading…
Cancel
Save