mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: make maximum number of payment parts configurable
This commit is contained in:
parent
5588876b48
commit
12ae3d6a40
4 changed files with 35 additions and 27 deletions
|
|
@ -108,6 +108,11 @@ type ClientConfig struct {
|
|||
// MaxLsatFee is the maximum that we are willing to pay in routing fees
|
||||
// to obtain the token.
|
||||
MaxLsatFee btcutil.Amount
|
||||
|
||||
// LoopOutMaxParts defines the maximum number of parts that may be used
|
||||
// for a loop out swap. When greater than one, a multi-part payment may
|
||||
// be attempted.
|
||||
LoopOutMaxParts uint32
|
||||
}
|
||||
|
||||
// NewClient returns a new instance to initiate swaps with.
|
||||
|
|
@ -145,6 +150,7 @@ func NewClient(dbDir string, cfg *ClientConfig) (*Client, func(), error) {
|
|||
store: store,
|
||||
sweeper: sweeper,
|
||||
createExpiryTimer: config.CreateExpiryTimer,
|
||||
loopOutMaxParts: cfg.LoopOutMaxParts,
|
||||
})
|
||||
|
||||
client := &Client{
|
||||
|
|
|
|||
11
executor.go
11
executor.go
|
|
@ -22,6 +22,8 @@ type executorConfig struct {
|
|||
store loopdb.SwapStore
|
||||
|
||||
createExpiryTimer func(expiry time.Duration) <-chan time.Time
|
||||
|
||||
loopOutMaxParts uint32
|
||||
}
|
||||
|
||||
// executor is responsible for executing swaps.
|
||||
|
|
@ -109,10 +111,11 @@ func (s *executor) run(mainCtx context.Context,
|
|||
defer s.wg.Done()
|
||||
|
||||
newSwap.execute(mainCtx, &executeConfig{
|
||||
statusChan: statusChan,
|
||||
sweeper: s.sweeper,
|
||||
blockEpochChan: queue.ChanOut(),
|
||||
timerFactory: s.executorConfig.createExpiryTimer,
|
||||
statusChan: statusChan,
|
||||
sweeper: s.sweeper,
|
||||
blockEpochChan: queue.ChanOut(),
|
||||
timerFactory: s.executorConfig.createExpiryTimer,
|
||||
loopOutMaxParts: s.executorConfig.loopOutMaxParts,
|
||||
}, height)
|
||||
|
||||
select {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ var (
|
|||
defaultLogFilename = "loopd.log"
|
||||
defaultLogDir = filepath.Join(loopDirBase, defaultLogDirname)
|
||||
|
||||
defaultMaxLogFiles = 3
|
||||
defaultMaxLogFileSize = 10
|
||||
defaultMaxLogFiles = 3
|
||||
defaultMaxLogFileSize = 10
|
||||
defaultLoopOutMaxParts = uint32(5)
|
||||
)
|
||||
|
||||
type lndConfig struct {
|
||||
|
|
@ -45,6 +46,8 @@ type config struct {
|
|||
MaxLSATCost uint32 `long:"maxlsatcost" description:"Maximum cost in satoshis that loopd is going to pay for an LSAT token automatically. Does not include routing fees."`
|
||||
MaxLSATFee uint32 `long:"maxlsatfee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an LSAT token."`
|
||||
|
||||
LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."`
|
||||
|
||||
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
|
||||
Proxy string `long:"proxy" description:"The host:port of a SOCKS proxy through which all connections to the swap server will be established over."`
|
||||
|
||||
|
|
@ -57,16 +60,17 @@ const (
|
|||
)
|
||||
|
||||
var defaultConfig = config{
|
||||
Network: "mainnet",
|
||||
RPCListen: "localhost:11010",
|
||||
RESTListen: "localhost:8081",
|
||||
Insecure: false,
|
||||
LogDir: defaultLogDir,
|
||||
MaxLogFiles: defaultMaxLogFiles,
|
||||
MaxLogFileSize: defaultMaxLogFileSize,
|
||||
DebugLevel: defaultLogLevel,
|
||||
MaxLSATCost: lsat.DefaultMaxCostSats,
|
||||
MaxLSATFee: lsat.DefaultMaxRoutingFeeSats,
|
||||
Network: "mainnet",
|
||||
RPCListen: "localhost:11010",
|
||||
RESTListen: "localhost:8081",
|
||||
Insecure: false,
|
||||
LogDir: defaultLogDir,
|
||||
MaxLogFiles: defaultMaxLogFiles,
|
||||
MaxLogFileSize: defaultMaxLogFileSize,
|
||||
DebugLevel: defaultLogLevel,
|
||||
MaxLSATCost: lsat.DefaultMaxCostSats,
|
||||
MaxLSATFee: lsat.DefaultMaxRoutingFeeSats,
|
||||
LoopOutMaxParts: defaultLoopOutMaxParts,
|
||||
Lnd: &lndConfig{
|
||||
Host: "localhost:10009",
|
||||
},
|
||||
|
|
|
|||
17
loopout.go
17
loopout.go
|
|
@ -45,12 +45,6 @@ var (
|
|||
paymentTimeout = time.Minute
|
||||
)
|
||||
|
||||
const (
|
||||
// loopOutMaxShards defines that maximum number of shards that may be
|
||||
// used for a loop out swap.
|
||||
loopOutMaxShards = 5
|
||||
)
|
||||
|
||||
// loopOutSwap contains all the in-memory state related to a pending loop out
|
||||
// swap.
|
||||
type loopOutSwap struct {
|
||||
|
|
@ -64,10 +58,11 @@ type loopOutSwap struct {
|
|||
|
||||
// executeConfig contains extra configuration to execute the swap.
|
||||
type executeConfig struct {
|
||||
sweeper *sweep.Sweeper
|
||||
statusChan chan<- SwapInfo
|
||||
blockEpochChan <-chan interface{}
|
||||
timerFactory func(d time.Duration) <-chan time.Time
|
||||
sweeper *sweep.Sweeper
|
||||
statusChan chan<- SwapInfo
|
||||
blockEpochChan <-chan interface{}
|
||||
timerFactory func(d time.Duration) <-chan time.Time
|
||||
loopOutMaxParts uint32
|
||||
}
|
||||
|
||||
// newLoopOutSwap initiates a new swap with the server and returns a
|
||||
|
|
@ -462,7 +457,7 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
|
|||
Invoice: invoice,
|
||||
OutgoingChannel: outgoingChannel,
|
||||
Timeout: paymentTimeout,
|
||||
MaxParts: loopOutMaxShards,
|
||||
MaxParts: s.executeConfig.loopOutMaxParts,
|
||||
}
|
||||
|
||||
// Lookup state of the swap payment.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue