mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 16:55:13 +02:00
routing: prefix MC logs with namespace
This commit is contained in:
@@ -7,7 +7,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
|
"github.com/btcsuite/btclog"
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/clock"
|
"github.com/lightningnetwork/lnd/clock"
|
||||||
"github.com/lightningnetwork/lnd/fn"
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
@@ -127,6 +129,8 @@ type MissionControl struct {
|
|||||||
// mission control state is updated.
|
// mission control state is updated.
|
||||||
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
||||||
|
|
||||||
|
log btclog.Logger
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +278,10 @@ func NewMissionController(db kvdb.Backend, self route.Vertex,
|
|||||||
state: newMissionControlState(cfg.MinFailureRelaxInterval),
|
state: newMissionControlState(cfg.MinFailureRelaxInterval),
|
||||||
store: store,
|
store: store,
|
||||||
estimator: cfg.Estimator,
|
estimator: cfg.Estimator,
|
||||||
|
log: build.NewPrefixLog(
|
||||||
|
fmt.Sprintf("[%s]:", DefaultMissionControlNamespace),
|
||||||
|
log,
|
||||||
|
),
|
||||||
onConfigUpdate: cfg.OnConfigUpdate,
|
onConfigUpdate: cfg.OnConfigUpdate,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +318,7 @@ func (m *MissionController) StopStoreTicker() {
|
|||||||
|
|
||||||
// init initializes mission control with historical data.
|
// init initializes mission control with historical data.
|
||||||
func (m *MissionControl) init() error {
|
func (m *MissionControl) init() error {
|
||||||
log.Debugf("Mission control state reconstruction started")
|
m.log.Debugf("Mission control state reconstruction started")
|
||||||
|
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
@@ -326,7 +334,7 @@ func (m *MissionControl) init() error {
|
|||||||
_ = m.applyPaymentResult(result)
|
_ = m.applyPaymentResult(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Mission control state reconstruction finished: "+
|
m.log.Debugf("Mission control state reconstruction finished: "+
|
||||||
"n=%v, time=%v", len(results), time.Since(start))
|
"n=%v, time=%v", len(results), time.Since(start))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -361,7 +369,7 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
|
m.log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
|
||||||
cfg.Estimator)
|
cfg.Estimator)
|
||||||
|
|
||||||
m.store.maxRecords = cfg.MaxMcHistory
|
m.store.maxRecords = cfg.MaxMcHistory
|
||||||
@@ -388,7 +396,7 @@ func (m *MissionControl) ResetHistory() error {
|
|||||||
|
|
||||||
m.state.resetHistory()
|
m.state.resetHistory()
|
||||||
|
|
||||||
log.Debugf("Mission control history cleared")
|
m.log.Debugf("Mission control history cleared")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -420,7 +428,7 @@ func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
log.Debugf("Requesting history snapshot from mission control")
|
m.log.Debugf("Requesting history snapshot from mission control")
|
||||||
|
|
||||||
return m.state.getSnapshot()
|
return m.state.getSnapshot()
|
||||||
}
|
}
|
||||||
@@ -438,12 +446,12 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
log.Infof("Importing history snapshot with %v pairs to mission control",
|
m.log.Infof("Importing history snapshot with %v pairs to mission "+
|
||||||
len(history.Pairs))
|
"control", len(history.Pairs))
|
||||||
|
|
||||||
imported := m.state.importSnapshot(history, force)
|
imported := m.state.importSnapshot(history, force)
|
||||||
|
|
||||||
log.Infof("Imported %v results to mission control", imported)
|
m.log.Infof("Imported %v results to mission control", imported)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -567,7 +575,7 @@ func (m *MissionControl) applyPaymentResult(
|
|||||||
// that case, a node-level failure would not be applied to untried
|
// that case, a node-level failure would not be applied to untried
|
||||||
// channels.
|
// channels.
|
||||||
if i.nodeFailure != nil {
|
if i.nodeFailure != nil {
|
||||||
log.Debugf("Reporting node failure to Mission Control: "+
|
m.log.Debugf("Reporting node failure to Mission Control: "+
|
||||||
"node=%v", *i.nodeFailure)
|
"node=%v", *i.nodeFailure)
|
||||||
|
|
||||||
m.state.setAllFail(*i.nodeFailure, result.timeReply)
|
m.state.setAllFail(*i.nodeFailure, result.timeReply)
|
||||||
@@ -577,11 +585,11 @@ func (m *MissionControl) applyPaymentResult(
|
|||||||
pairResult := pairResult
|
pairResult := pairResult
|
||||||
|
|
||||||
if pairResult.success {
|
if pairResult.success {
|
||||||
log.Debugf("Reporting pair success to Mission "+
|
m.log.Debugf("Reporting pair success to Mission "+
|
||||||
"Control: pair=%v, amt=%v",
|
"Control: pair=%v, amt=%v",
|
||||||
pair, pairResult.amt)
|
pair, pairResult.amt)
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("Reporting pair failure to Mission "+
|
m.log.Debugf("Reporting pair failure to Mission "+
|
||||||
"Control: pair=%v, amt=%v",
|
"Control: pair=%v, amt=%v",
|
||||||
pair, pairResult.amt)
|
pair, pairResult.amt)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user