Merge pull request #9212 from ellemouton/slogFollowUps
multi: update log dep for sub-modules
This commit is contained in:
19 files changed
+109
-52
No files matched your search
+18
-3
@@ -9,8 +9,10 @@ import (
|
|||||||
// NewDefaultLogHandlers returns the standard console logger and rotating log
|
// NewDefaultLogHandlers returns the standard console logger and rotating log
|
||||||
// writer handlers that we generally want to use. It also applies the various
|
// writer handlers that we generally want to use. It also applies the various
|
||||||
// config options to the loggers.
|
// config options to the loggers.
|
||||||
func NewDefaultLogHandlers(cfg *LogConfig, rotator *RotatingLogWriter) (
|
func NewDefaultLogHandlers(cfg *LogConfig,
|
||||||
btclog.Handler, btclog.Handler) {
|
rotator *RotatingLogWriter) []btclog.Handler {
|
||||||
|
|
||||||
|
var handlers []btclog.Handler
|
||||||
|
|
||||||
consoleLogHandler := btclog.NewDefaultHandler(
|
consoleLogHandler := btclog.NewDefaultHandler(
|
||||||
os.Stdout, cfg.Console.HandlerOptions()...,
|
os.Stdout, cfg.Console.HandlerOptions()...,
|
||||||
@@ -19,5 +21,18 @@ func NewDefaultLogHandlers(cfg *LogConfig, rotator *RotatingLogWriter) (
|
|||||||
rotator, cfg.File.HandlerOptions()...,
|
rotator, cfg.File.HandlerOptions()...,
|
||||||
)
|
)
|
||||||
|
|
||||||
return consoleLogHandler, logFileHandler
|
maybeAddLogger := func(cmdOptionDisable bool, handler btclog.Handler) {
|
||||||
|
if !cmdOptionDisable {
|
||||||
|
handlers = append(handlers, handler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch LoggingType {
|
||||||
|
case LogTypeStdOut:
|
||||||
|
maybeAddLogger(cfg.Console.Disable, consoleLogHandler)
|
||||||
|
case LogTypeDefault:
|
||||||
|
maybeAddLogger(cfg.Console.Disable, consoleLogHandler)
|
||||||
|
maybeAddLogger(cfg.File.Disable, logFileHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
return handlers
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btclog/v2"
|
|
||||||
flags "github.com/jessevdk/go-flags"
|
flags "github.com/jessevdk/go-flags"
|
||||||
"github.com/lightninglabs/neutrino"
|
"github.com/lightninglabs/neutrino"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
@@ -1404,32 +1403,14 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name),
|
lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name),
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
logCfg = cfg.LogConfig
|
|
||||||
logHandlers []btclog.Handler
|
|
||||||
consoleLogHandler, logFileHandler = build.NewDefaultLogHandlers(
|
|
||||||
logCfg, cfg.LogRotator,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
maybeAddLogger := func(cmdOptionDisable bool, handler btclog.Handler) {
|
|
||||||
if !cmdOptionDisable {
|
|
||||||
logHandlers = append(logHandlers, handler)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch build.LoggingType {
|
|
||||||
case build.LogTypeStdOut:
|
|
||||||
maybeAddLogger(logCfg.Console.Disable, consoleLogHandler)
|
|
||||||
case build.LogTypeDefault:
|
|
||||||
maybeAddLogger(logCfg.Console.Disable, consoleLogHandler)
|
|
||||||
maybeAddLogger(logCfg.File.Disable, logFileHandler)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !build.SuportedLogCompressor(cfg.LogCompressor) {
|
if !build.SuportedLogCompressor(cfg.LogCompressor) {
|
||||||
return nil, mkErr("invalid log compressor: %v",
|
return nil, mkErr("invalid log compressor: %v",
|
||||||
cfg.LogCompressor)
|
cfg.LogCompressor)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.SubLogMgr = build.NewSubLoggerManager(logHandlers...)
|
cfg.SubLogMgr = build.NewSubLoggerManager(build.NewDefaultLogHandlers(
|
||||||
|
cfg.LogConfig, cfg.LogRotator,
|
||||||
|
)...)
|
||||||
|
|
||||||
// Initialize logging at the default logging level.
|
// Initialize logging at the default logging level.
|
||||||
SetupLoggers(cfg.SubLogMgr, interceptor)
|
SetupLoggers(cfg.SubLogMgr, interceptor)
|
||||||
|
|||||||
+4
-3
@@ -1,9 +1,7 @@
|
|||||||
module github.com/lightningnetwork/lnd/healthcheck
|
module github.com/lightningnetwork/lnd/healthcheck
|
||||||
|
|
||||||
go 1.19
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
|
||||||
github.com/lightningnetwork/lnd/ticker v1.1.0
|
github.com/lightningnetwork/lnd/ticker v1.1.0
|
||||||
github.com/lightningnetwork/lnd/tor v1.0.0
|
github.com/lightningnetwork/lnd/tor v1.0.0
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
@@ -13,6 +11,7 @@ require (
|
|||||||
require (
|
require (
|
||||||
github.com/btcsuite/btcd v0.23.2 // indirect
|
github.com/btcsuite/btcd v0.23.2 // indirect
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/kr/pretty v0.3.0 // indirect
|
github.com/kr/pretty v0.3.0 // indirect
|
||||||
github.com/miekg/dns v1.1.43 // indirect
|
github.com/miekg/dns v1.1.43 // indirect
|
||||||
@@ -24,3 +23,5 @@ require (
|
|||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go 1.21
|
||||||
+4
-1
@@ -9,8 +9,11 @@ github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9Ur
|
|||||||
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
|
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c h1:4HxD1lBUGUddhzgaNgrCPsFWd7cGYNpeFUgd9ZIgyM0=
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
||||||
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
||||||
|
|||||||
+1
-3
@@ -1,8 +1,6 @@
|
|||||||
package healthcheck
|
package healthcheck
|
||||||
|
|
||||||
import (
|
import "github.com/btcsuite/btclog/v2"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Subsystem defines the logging code for this subsystem.
|
// Subsystem defines the logging code for this subsystem.
|
||||||
const Subsystem = "HLCK"
|
const Subsystem = "HLCK"
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
module github.com/lightningnetwork/lnd/kvdb
|
module github.com/lightningnetwork/lnd/kvdb
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
|
||||||
github.com/btcsuite/btcwallet/walletdb v1.4.4
|
github.com/btcsuite/btcwallet/walletdb v1.4.4
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/fergusstrange/embedded-postgres v1.25.0
|
github.com/fergusstrange/embedded-postgres v1.25.0
|
||||||
@@ -26,6 +26,7 @@ require (
|
|||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/btcsuite/btcd v0.23.2 // indirect
|
github.com/btcsuite/btcd v0.23.2 // indirect
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
github.com/containerd/continuity v0.3.0 // indirect
|
github.com/containerd/continuity v0.3.0 // indirect
|
||||||
|
|||||||
+4
-1
@@ -37,8 +37,11 @@ github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9Ur
|
|||||||
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
|
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c h1:4HxD1lBUGUddhzgaNgrCPsFWd7cGYNpeFUgd9ZIgyM0=
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||||
github.com/btcsuite/btcwallet/walletdb v1.4.4 h1:BDel6iT/ltYSIYKs0YbjwnEDi7xR3yzABIsQxN2F1L8=
|
github.com/btcsuite/btcwallet/walletdb v1.4.4 h1:BDel6iT/ltYSIYKs0YbjwnEDi7xR3yzABIsQxN2F1L8=
|
||||||
github.com/btcsuite/btcwallet/walletdb v1.4.4/go.mod h1:jk/hvpLFINF0C1kfTn0bfx2GbnFT+Nvnj6eblZALfjs=
|
github.com/btcsuite/btcwallet/walletdb v1.4.4/go.mod h1:jk/hvpLFINF0C1kfTn0bfx2GbnFT+Nvnj6eblZALfjs=
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package kvdb
|
package kvdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/btcsuite/btclog"
|
"github.com/btcsuite/btclog/v2"
|
||||||
"github.com/lightningnetwork/lnd/kvdb/sqlbase"
|
"github.com/lightningnetwork/lnd/kvdb/sqlbase"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func newPostgresBackend(ctx context.Context, config *Config, prefix string) (
|
|||||||
Schema: "public",
|
Schema: "public",
|
||||||
TableNamePrefix: prefix,
|
TableNamePrefix: prefix,
|
||||||
SQLiteCmdReplacements: sqliteCmdReplacements,
|
SQLiteCmdReplacements: sqliteCmdReplacements,
|
||||||
|
WithTxLevelLock: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return sqlbase.NewSqlBackend(ctx, cfg)
|
return sqlbase.NewSqlBackend(ctx, cfg)
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ type Config struct {
|
|||||||
// commands. Note that the sqlite keywords to be replaced are
|
// commands. Note that the sqlite keywords to be replaced are
|
||||||
// case-sensitive.
|
// case-sensitive.
|
||||||
SQLiteCmdReplacements SQLiteCmdReplacements
|
SQLiteCmdReplacements SQLiteCmdReplacements
|
||||||
|
|
||||||
|
// WithTxLevelLock when set will ensure that there is a transaction
|
||||||
|
// level lock.
|
||||||
|
WithTxLevelLock bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// db holds a reference to the sql db connection.
|
// db holds a reference to the sql db connection.
|
||||||
@@ -75,6 +79,10 @@ type db struct {
|
|||||||
// db is the underlying database connection instance.
|
// db is the underlying database connection instance.
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
|
|
||||||
|
// lock is the global write lock that ensures single writer. This is
|
||||||
|
// only used if cfg.WithTxLevelLock is set.
|
||||||
|
lock sync.RWMutex
|
||||||
|
|
||||||
// table is the name of the table that contains the data for all
|
// table is the name of the table that contains the data for all
|
||||||
// top-level buckets that have keys that cannot be mapped to a distinct
|
// top-level buckets that have keys that cannot be mapped to a distinct
|
||||||
// sql table.
|
// sql table.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package sqlbase
|
package sqlbase
|
||||||
|
|
||||||
import "github.com/btcsuite/btclog"
|
import "github.com/btcsuite/btclog/v2"
|
||||||
|
|
||||||
// log is a logger that is initialized as disabled. This means the package will
|
// log is a logger that is initialized as disabled. This means the package will
|
||||||
// not perform any logging by default until a logger is set.
|
// not perform any logging by default until a logger is set.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package sqlbase
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
)
|
)
|
||||||
@@ -19,11 +20,28 @@ type readWriteTx struct {
|
|||||||
|
|
||||||
// active is true if the transaction hasn't been committed yet.
|
// active is true if the transaction hasn't been committed yet.
|
||||||
active bool
|
active bool
|
||||||
|
|
||||||
|
// locker is a pointer to the global db lock.
|
||||||
|
locker sync.Locker
|
||||||
}
|
}
|
||||||
|
|
||||||
// newReadWriteTx creates an rw transaction using a connection from the
|
// newReadWriteTx creates an rw transaction using a connection from the
|
||||||
// specified pool.
|
// specified pool.
|
||||||
func newReadWriteTx(db *db, readOnly bool) (*readWriteTx, error) {
|
func newReadWriteTx(db *db, readOnly bool) (*readWriteTx, error) {
|
||||||
|
locker := newNoopLocker()
|
||||||
|
if db.cfg.WithTxLevelLock {
|
||||||
|
// Obtain the global lock instance. An alternative here is to
|
||||||
|
// obtain a database lock from Postgres. Unfortunately there is
|
||||||
|
// no database-level lock in Postgres, meaning that each table
|
||||||
|
// would need to be locked individually. Perhaps an advisory
|
||||||
|
// lock could perform this function too.
|
||||||
|
locker = &db.lock
|
||||||
|
if readOnly {
|
||||||
|
locker = db.lock.RLocker()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
locker.Lock()
|
||||||
|
|
||||||
// Start the transaction. Don't use the timeout context because it would
|
// Start the transaction. Don't use the timeout context because it would
|
||||||
// be applied to the transaction as a whole. If possible, mark the
|
// be applied to the transaction as a whole. If possible, mark the
|
||||||
// transaction as read-only to make sure that potential programming
|
// transaction as read-only to make sure that potential programming
|
||||||
@@ -36,6 +54,7 @@ func newReadWriteTx(db *db, readOnly bool) (*readWriteTx, error) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
locker.Unlock()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +62,7 @@ func newReadWriteTx(db *db, readOnly bool) (*readWriteTx, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
tx: tx,
|
tx: tx,
|
||||||
active: true,
|
active: true,
|
||||||
|
locker: locker,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +94,7 @@ func (tx *readWriteTx) Rollback() error {
|
|||||||
|
|
||||||
// Unlock the transaction regardless of the error result.
|
// Unlock the transaction regardless of the error result.
|
||||||
tx.active = false
|
tx.active = false
|
||||||
|
tx.locker.Unlock()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +162,7 @@ func (tx *readWriteTx) Commit() error {
|
|||||||
|
|
||||||
// Unlock the transaction regardless of the error result.
|
// Unlock the transaction regardless of the error result.
|
||||||
tx.active = false
|
tx.active = false
|
||||||
|
tx.locker.Unlock()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -182,3 +204,25 @@ func (tx *readWriteTx) Exec(query string, args ...interface{}) (sql.Result,
|
|||||||
|
|
||||||
return tx.tx.ExecContext(ctx, query, args...)
|
return tx.tx.ExecContext(ctx, query, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noopLocker is an implementation of a no-op sync.Locker.
|
||||||
|
type noopLocker struct{}
|
||||||
|
|
||||||
|
// newNoopLocker creates a new noopLocker.
|
||||||
|
func newNoopLocker() sync.Locker {
|
||||||
|
return &noopLocker{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock is a noop.
|
||||||
|
//
|
||||||
|
// NOTE: this is part of the sync.Locker interface.
|
||||||
|
func (n *noopLocker) Lock() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock is a noop.
|
||||||
|
//
|
||||||
|
// NOTE: this is part of the sync.Locker interface.
|
||||||
|
func (n *noopLocker) Unlock() {
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ sync.Locker = (*noopLocker)(nil)
|
||||||
+4
-3
@@ -1,9 +1,7 @@
|
|||||||
module github.com/lightningnetwork/lnd/sqldb
|
module github.com/lightningnetwork/lnd/sqldb
|
||||||
|
|
||||||
go 1.21.4
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
|
||||||
github.com/golang-migrate/migrate/v4 v4.17.0
|
github.com/golang-migrate/migrate/v4 v4.17.0
|
||||||
github.com/jackc/pgconn v1.14.3
|
github.com/jackc/pgconn v1.14.3
|
||||||
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
|
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
|
||||||
@@ -18,6 +16,7 @@ require (
|
|||||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
|
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||||
github.com/containerd/continuity v0.3.0 // indirect
|
github.com/containerd/continuity v0.3.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
@@ -68,3 +67,5 @@ require (
|
|||||||
modernc.org/strutil v1.2.0 // indirect
|
modernc.org/strutil v1.2.0 // indirect
|
||||||
modernc.org/token v1.1.0 // indirect
|
modernc.org/token v1.1.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go 1.21.4
|
||||||
+4
-2
@@ -5,8 +5,10 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
|
|||||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
|
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
|
||||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
|
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c h1:4HxD1lBUGUddhzgaNgrCPsFWd7cGYNpeFUgd9ZIgyM0=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
|
||||||
github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4=
|
github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4=
|
||||||
github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||||
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
|
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
|
||||||
|
|||||||
+1
-3
@@ -1,8 +1,6 @@
|
|||||||
package sqldb
|
package sqldb
|
||||||
|
|
||||||
import (
|
import "github.com/btcsuite/btclog/v2"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Subsystem defines the logging code for this subsystem.
|
// Subsystem defines the logging code for this subsystem.
|
||||||
const Subsystem = "SQLD"
|
const Subsystem = "SQLD"
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/btcsuite/btclog"
|
"github.com/btcsuite/btclog/v2"
|
||||||
"github.com/golang-migrate/migrate/v4"
|
"github.com/golang-migrate/migrate/v4"
|
||||||
"github.com/golang-migrate/migrate/v4/database"
|
"github.com/golang-migrate/migrate/v4/database"
|
||||||
"github.com/golang-migrate/migrate/v4/source/httpfs"
|
"github.com/golang-migrate/migrate/v4/source/httpfs"
|
||||||
|
|||||||
+3
-2
@@ -2,7 +2,7 @@ module github.com/lightningnetwork/lnd/tor
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btcd v0.23.3
|
github.com/btcsuite/btcd v0.23.3
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
|
||||||
github.com/miekg/dns v1.1.43
|
github.com/miekg/dns v1.1.43
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
golang.org/x/net v0.17.0
|
golang.org/x/net v0.17.0
|
||||||
@@ -10,6 +10,7 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||||
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/kr/pretty v0.3.0 // indirect
|
github.com/kr/pretty v0.3.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
@@ -22,4 +23,4 @@ require (
|
|||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.19
|
go 1.21
|
||||||
+4
-2
@@ -2,8 +2,10 @@ github.com/btcsuite/btcd v0.23.3 h1:4KH/JKy9WiCd+iUS9Mu0Zp7Dnj17TGdKrg9xc/FGj24=
|
|||||||
github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c h1:4HxD1lBUGUddhzgaNgrCPsFWd7cGYNpeFUgd9ZIgyM0=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
|
||||||
|
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
|||||||
+1
-3
@@ -1,8 +1,6 @@
|
|||||||
package tor
|
package tor
|
||||||
|
|
||||||
import (
|
import "github.com/btcsuite/btclog/v2"
|
||||||
"github.com/btcsuite/btclog"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Subsystem defines the logging code for this subsystem.
|
// Subsystem defines the logging code for this subsystem.
|
||||||
const Subsystem = "TORC" // TORC as in Tor Controller.
|
const Subsystem = "TORC" // TORC as in Tor Controller.
|
||||||
|
|||||||
Reference in new issue
Block a user