multi: add cancel swap function to execute config

pull/378/head
carla 3 years ago
parent 4040bb356d
commit 16111352a8
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -142,6 +142,7 @@ func NewClient(dbDir string, cfg *ClientConfig) (*Client, func(), error) {
sweeper: sweeper, sweeper: sweeper,
createExpiryTimer: config.CreateExpiryTimer, createExpiryTimer: config.CreateExpiryTimer,
loopOutMaxParts: cfg.LoopOutMaxParts, loopOutMaxParts: cfg.LoopOutMaxParts,
cancelSwap: swapServerClient.CancelLoopOutSwap,
}) })
client := &Client{ client := &Client{

@ -25,6 +25,8 @@ type executorConfig struct {
createExpiryTimer func(expiry time.Duration) <-chan time.Time createExpiryTimer func(expiry time.Duration) <-chan time.Time
loopOutMaxParts uint32 loopOutMaxParts uint32
cancelSwap func(ctx context.Context, details *outCancelDetails) error
} }
// executor is responsible for executing swaps. // executor is responsible for executing swaps.
@ -144,6 +146,7 @@ func (s *executor) run(mainCtx context.Context,
blockEpochChan: queue.ChanOut(), blockEpochChan: queue.ChanOut(),
timerFactory: s.executorConfig.createExpiryTimer, timerFactory: s.executorConfig.createExpiryTimer,
loopOutMaxParts: s.executorConfig.loopOutMaxParts, loopOutMaxParts: s.executorConfig.loopOutMaxParts,
cancelSwap: s.executorConfig.cancelSwap,
}, height) }, height)
select { select {

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

@ -75,6 +75,7 @@ type executeConfig struct {
blockEpochChan <-chan interface{} blockEpochChan <-chan interface{}
timerFactory func(d time.Duration) <-chan time.Time timerFactory func(d time.Duration) <-chan time.Time
loopOutMaxParts uint32 loopOutMaxParts uint32
cancelSwap func(context.Context, *outCancelDetails) error
} }
// loopOutInitResult contains information about a just-initiated loop out swap. // loopOutInitResult contains information about a just-initiated loop out swap.

@ -73,6 +73,7 @@ func TestLoopOutPaymentParameters(t *testing.T) {
blockEpochChan: blockEpochChan, blockEpochChan: blockEpochChan,
timerFactory: timerFactory, timerFactory: timerFactory,
loopOutMaxParts: maxParts, loopOutMaxParts: maxParts,
cancelSwap: server.CancelLoopOutSwap,
}, height) }, height)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
@ -173,6 +174,7 @@ func TestLateHtlcPublish(t *testing.T) {
sweeper: sweeper, sweeper: sweeper,
blockEpochChan: blockEpochChan, blockEpochChan: blockEpochChan,
timerFactory: timerFactory, timerFactory: timerFactory,
cancelSwap: server.CancelLoopOutSwap,
}, height) }, height)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
@ -267,6 +269,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
blockEpochChan: blockEpochChan, blockEpochChan: blockEpochChan,
timerFactory: timerFactory, timerFactory: timerFactory,
sweeper: sweeper, sweeper: sweeper,
cancelSwap: server.CancelLoopOutSwap,
}, ctx.Lnd.Height) }, ctx.Lnd.Height)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
@ -461,6 +464,7 @@ func TestPreimagePush(t *testing.T) {
blockEpochChan: blockEpochChan, blockEpochChan: blockEpochChan,
timerFactory: timerFactory, timerFactory: timerFactory,
sweeper: sweeper, sweeper: sweeper,
cancelSwap: server.CancelLoopOutSwap,
}, ctx.Lnd.Height) }, ctx.Lnd.Height)
if err != nil { if err != nil {
log.Error(err) log.Error(err)

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

Loading…
Cancel
Save