Skip to content

Commit 2f27a52

Browse files
committed
server+lncfg: make sweepr batch window duration configurable
1 parent 1aa4d04 commit 2f27a52

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/lightningnetwork/lnd/lnwallet"
4242
"github.com/lightningnetwork/lnd/routing"
4343
"github.com/lightningnetwork/lnd/signal"
44+
"github.com/lightningnetwork/lnd/sweep"
4445
"github.com/lightningnetwork/lnd/tor"
4546
)
4647

@@ -439,6 +440,8 @@ type Config struct {
439440

440441
RemoteSigner *lncfg.RemoteSigner `group:"remotesigner" namespace:"remotesigner"`
441442

443+
Sweeper *lncfg.Sweeper `group:"sweeper" namespace:"sweeper"`
444+
442445
// LogWriter is the root logger that all of the daemon's subloggers are
443446
// hooked up to.
444447
LogWriter *build.RotatingLogWriter
@@ -635,6 +638,9 @@ func DefaultConfig() Config {
635638
RemoteSigner: &lncfg.RemoteSigner{
636639
Timeout: lncfg.DefaultRemoteSignerRPCTimeout,
637640
},
641+
Sweeper: &lncfg.Sweeper{
642+
BatchWindowDuration: sweep.DefaultBatchWindowDuration,
643+
},
638644
}
639645
}
640646

@@ -1651,6 +1657,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
16511657
cfg.HealthChecks,
16521658
cfg.RPCMiddleware,
16531659
cfg.RemoteSigner,
1660+
cfg.Sweeper,
16541661
)
16551662
if err != nil {
16561663
return nil, err

lncfg/sweeper.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package lncfg
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
type Sweeper struct {
9+
BatchWindowDuration time.Duration `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input."`
10+
}
11+
12+
// Validate checks the values configured for the sweeper.
13+
func (s *Sweeper) Validate() error {
14+
if s.BatchWindowDuration < 0 {
15+
return fmt.Errorf("batchwindowduration must be positive")
16+
}
17+
18+
return nil
19+
}

sample-lnd.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,3 +1415,10 @@ litecoin.node=ltcd
14151415
; for neutrino nodes as it means they'll only maintain edges where both nodes are
14161416
; seen as being live from it's PoV.
14171417
; routing.strictgraphpruning=true
1418+
1419+
[sweeper]
1420+
1421+
; Duration of the sweep batch window. The sweep is held back during the batch
1422+
; window to allow more inputs to be added and thereby lower the fee per input.
1423+
; sweeper.batchwindowduration=30s
1424+

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
10041004
Signer: cc.Wallet.Cfg.Signer,
10051005
Wallet: cc.Wallet,
10061006
NewBatchTimer: func() <-chan time.Time {
1007-
return time.NewTimer(sweep.DefaultBatchWindowDuration).C
1007+
return time.NewTimer(cfg.Sweeper.BatchWindowDuration).C
10081008
},
10091009
Notifier: cc.ChainNotifier,
10101010
Store: sweeperStore,

0 commit comments

Comments
 (0)