mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: allow setting RPC batch size when running cost migration
Previously we defaulted to fetching 1000 payments at a time when running the cost migration however due to slowness on LND side this may prevent the migration from completing due to RPC timeout kicking in. This commit adds a new config value to give more control to the user by setting the batch size as needed.
This commit is contained in:
parent
6db2a39331
commit
0e2a36004a
4 changed files with 35 additions and 23 deletions
|
|
@ -48,6 +48,12 @@ var (
|
|||
defaultTotalPaymentTimeout = time.Minute * 60
|
||||
defaultMaxPaymentRetries = 3
|
||||
|
||||
// defaultRPCBatchSize is the default batch size to use for RPC calls
|
||||
// we make to LND during migrations. If operations on the LND side are
|
||||
// too slow a too large batch size may prevent the migration from
|
||||
// completing.
|
||||
defaultRPCBatchSize = 1000
|
||||
|
||||
// DefaultTLSCertFilename is the default file name for the autogenerated
|
||||
// TLS certificate.
|
||||
DefaultTLSCertFilename = "tls.cert"
|
||||
|
|
@ -179,6 +185,8 @@ type Config struct {
|
|||
|
||||
EnableExperimental bool `long:"experimental" description:"Enable experimental features: reservations"`
|
||||
|
||||
MigrationRPCBatchSize int `long:"migrationrpcbatchsize" description:"The RPC batch size to use during migrations."`
|
||||
|
||||
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
|
||||
|
||||
Server *loopServerConfig `group:"server" namespace:"server"`
|
||||
|
|
@ -207,20 +215,21 @@ func DefaultConfig() Config {
|
|||
Sqlite: &loopdb.SqliteConfig{
|
||||
DatabaseFileName: defaultSqliteDatabasePath,
|
||||
},
|
||||
LogDir: defaultLogDir,
|
||||
MaxLogFiles: defaultMaxLogFiles,
|
||||
MaxLogFileSize: defaultMaxLogFileSize,
|
||||
DebugLevel: defaultLogLevel,
|
||||
TLSCertPath: DefaultTLSCertPath,
|
||||
TLSKeyPath: DefaultTLSKeyPath,
|
||||
TLSValidity: DefaultAutogenValidity,
|
||||
MacaroonPath: DefaultMacaroonPath,
|
||||
MaxL402Cost: l402.DefaultMaxCostSats,
|
||||
MaxL402Fee: l402.DefaultMaxRoutingFeeSats,
|
||||
LoopOutMaxParts: defaultLoopOutMaxParts,
|
||||
TotalPaymentTimeout: defaultTotalPaymentTimeout,
|
||||
MaxPaymentRetries: defaultMaxPaymentRetries,
|
||||
EnableExperimental: false,
|
||||
LogDir: defaultLogDir,
|
||||
MaxLogFiles: defaultMaxLogFiles,
|
||||
MaxLogFileSize: defaultMaxLogFileSize,
|
||||
DebugLevel: defaultLogLevel,
|
||||
TLSCertPath: DefaultTLSCertPath,
|
||||
TLSKeyPath: DefaultTLSKeyPath,
|
||||
TLSValidity: DefaultAutogenValidity,
|
||||
MacaroonPath: DefaultMacaroonPath,
|
||||
MaxL402Cost: l402.DefaultMaxCostSats,
|
||||
MaxL402Fee: l402.DefaultMaxRoutingFeeSats,
|
||||
LoopOutMaxParts: defaultLoopOutMaxParts,
|
||||
TotalPaymentTimeout: defaultTotalPaymentTimeout,
|
||||
MaxPaymentRetries: defaultMaxPaymentRetries,
|
||||
EnableExperimental: false,
|
||||
MigrationRPCBatchSize: defaultRPCBatchSize,
|
||||
Lnd: &lndConfig{
|
||||
Host: "localhost:10009",
|
||||
MacaroonPath: DefaultLndMacaroonPath,
|
||||
|
|
@ -367,6 +376,10 @@ func Validate(cfg *Config) error {
|
|||
return fmt.Errorf("TLS certificate minimum validity period is 24h")
|
||||
}
|
||||
|
||||
if cfg.MigrationRPCBatchSize <= 0 {
|
||||
return fmt.Errorf("migrationrpcbatchsize must be greater than 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -410,7 +410,10 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
|
|||
}
|
||||
|
||||
// Run the costs migration.
|
||||
err = loop.MigrateLoopOutCosts(d.mainCtx, d.lnd.LndServices, swapDb)
|
||||
err = loop.MigrateLoopOutCosts(
|
||||
d.mainCtx, d.lnd.LndServices, d.cfg.MigrationRPCBatchSize,
|
||||
swapDb,
|
||||
)
|
||||
if err != nil {
|
||||
log.Errorf("Cost migration failed: %v", err)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue