mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-13 12:32:48 +02:00
sqldb+lncfg: consolidate SQLite default constants
Move the SQLite default constants (max connections, busy timeout) to sqldb/config.go as the single source of truth and export them. Remove the duplicate definitions from lncfg/db.go and reference the sqldb constants instead.
This commit is contained in:
parent
d87d93b114
commit
325f83c179
2 changed files with 9 additions and 12 deletions
|
|
@ -40,9 +40,6 @@ const (
|
|||
DefaultBatchCommitInterval = 500 * time.Millisecond
|
||||
|
||||
defaultPostgresMaxConnections = 50
|
||||
defaultSqliteMaxConnections = 2
|
||||
|
||||
defaultSqliteBusyTimeout = 5 * time.Second
|
||||
|
||||
// NSChannelDB is the namespace name that we use for the combined graph
|
||||
// and channel state DB.
|
||||
|
|
@ -126,8 +123,8 @@ func DefaultDB() *DB {
|
|||
QueryConfig: *sqldb.DefaultPostgresConfig(),
|
||||
},
|
||||
Sqlite: &sqldb.SqliteConfig{
|
||||
MaxConnections: defaultSqliteMaxConnections,
|
||||
BusyTimeout: defaultSqliteBusyTimeout,
|
||||
MaxConnections: sqldb.DefaultSqliteMaxConns,
|
||||
BusyTimeout: sqldb.DefaultSqliteBusyTimeout,
|
||||
QueryConfig: *sqldb.DefaultSQLiteConfig(),
|
||||
},
|
||||
UseNativeSQL: false,
|
||||
|
|
|
|||
|
|
@ -32,15 +32,15 @@ type SqliteConfig struct {
|
|||
}
|
||||
|
||||
const (
|
||||
// defaultSqliteMaxConns is the default number of maximum open
|
||||
// DefaultSqliteMaxConns is the default number of maximum open
|
||||
// connections for SQLite. SQLite only supports a single writer, so a
|
||||
// low default reduces contention on the busy_timeout and limits
|
||||
// resource usage, especially on mobile.
|
||||
defaultSqliteMaxConns = 2
|
||||
DefaultSqliteMaxConns = 2
|
||||
|
||||
// defaultBusyTimeoutMs is the default busy_timeout value in
|
||||
// milliseconds, used when no BusyTimeout is configured.
|
||||
defaultBusyTimeoutMs = 5000
|
||||
// DefaultSqliteBusyTimeout is the default busy_timeout value used
|
||||
// when no BusyTimeout is configured.
|
||||
DefaultSqliteBusyTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
// busyTimeoutMs returns the busy_timeout value in milliseconds. If
|
||||
|
|
@ -50,7 +50,7 @@ func (s *SqliteConfig) busyTimeoutMs() int64 {
|
|||
return s.BusyTimeout.Milliseconds()
|
||||
}
|
||||
|
||||
return defaultBusyTimeoutMs
|
||||
return DefaultSqliteBusyTimeout.Milliseconds()
|
||||
}
|
||||
|
||||
// MaxConns returns the effective maximum number of open connections. If
|
||||
|
|
@ -62,7 +62,7 @@ func (s *SqliteConfig) MaxConns() int {
|
|||
return s.MaxConnections
|
||||
}
|
||||
|
||||
return defaultSqliteMaxConns
|
||||
return DefaultSqliteMaxConns
|
||||
}
|
||||
|
||||
// Validate checks that the SqliteConfig values are valid.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue