sqldb+lncfg: consolidate SQLite default constants
What changed, and why it matters
This commit is a simple code cleanup: it moves two default SQLite settings (maximum connections and busy timeout) into one shared location and removes duplicate copies elsewhere. The actual values stay exactly the same, so there is no security or functional change for users.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch consolidates default SQLite constants. It exports DefaultSqliteMaxConns (2) and DefaultSqliteBusyTimeout (5s) from sqldb/config.go, removes the duplicate unexported constants from lncfg/db.go, and updates references. Numeric values and behavior are unchanged; this is a pure refactor.
Changed components
lncfg/db.gosqldb/config.goInspect captured patch +9 / −12
diff --git a/lncfg/db.go b/lncfg/db.go
index 2dec1bd..6835382 100644
--- a/lncfg/db.go
+++ b/lncfg/db.go
@@ -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,
diff --git a/sqldb/config.go b/sqldb/config.go
index a5e8122..bf2a8de 100644
--- a/sqldb/config.go
+++ b/sqldb/config.go
@@ -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.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.