mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: abandon loop-ins
This commit is contained in:
parent
0fbf253391
commit
5e91c446b8
6 changed files with 161 additions and 3 deletions
15
executor.go
15
executor.go
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/sweep"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/queue"
|
||||
)
|
||||
|
||||
|
|
@ -46,6 +47,8 @@ type executor struct {
|
|||
currentHeight uint32
|
||||
ready chan struct{}
|
||||
|
||||
sync.Mutex
|
||||
|
||||
executorConfig
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +64,8 @@ func newExecutor(cfg *executorConfig) *executor {
|
|||
// run starts the executor event loop. It accepts and executes new swaps,
|
||||
// providing them with required config data.
|
||||
func (s *executor) run(mainCtx context.Context,
|
||||
statusChan chan<- SwapInfo) error {
|
||||
statusChan chan<- SwapInfo,
|
||||
abandonChans map[lntypes.Hash]chan struct{}) error {
|
||||
|
||||
var (
|
||||
err error
|
||||
|
|
@ -167,6 +171,15 @@ func (s *executor) run(mainCtx context.Context,
|
|||
log.Errorf("Execute error: %v", err)
|
||||
}
|
||||
|
||||
// If a loop-in ended we have to remove its
|
||||
// abandon channel from our abandonChans map
|
||||
// since the swap finalized.
|
||||
if swap, ok := newSwap.(*loopInSwap); ok {
|
||||
s.Lock()
|
||||
delete(abandonChans, swap.hash)
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
select {
|
||||
case swapDoneChan <- swapID:
|
||||
case <-mainCtx.Done():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue