mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-04 12:09:27 +02:00
routing: unexport MissionControl mutex
Only the MissionControl instance should use this variable and it should not be accessible to users of MissionControl.
This commit is contained in:
parent
6b449a6633
commit
28a828a11e
@ -121,7 +121,7 @@ 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)]
|
||||||
|
|
||||||
sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
||||||
// TODO(roasbeef): further counters, if vertex continually unavailable,
|
// TODO(roasbeef): further counters, if vertex continually unavailable,
|
||||||
// add to another generation
|
// add to another generation
|
||||||
@ -295,8 +295,8 @@ func (m *MissionControl) init() error {
|
|||||||
// with. All fields are copied by value, so we do not need to worry about
|
// with. All fields are copied by value, so we do not need to worry about
|
||||||
// mutation.
|
// mutation.
|
||||||
func (m *MissionControl) GetConfig() *MissionControlConfig {
|
func (m *MissionControl) GetConfig() *MissionControlConfig {
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
return &MissionControlConfig{
|
return &MissionControlConfig{
|
||||||
Estimator: m.estimator,
|
Estimator: m.estimator,
|
||||||
@ -317,8 +317,8 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
|
log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
|
||||||
cfg.Estimator)
|
cfg.Estimator)
|
||||||
@ -338,8 +338,8 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
|
|||||||
// ResetHistory resets the history of MissionControl returning it to a state as
|
// ResetHistory resets the history of MissionControl returning it to a state as
|
||||||
// if no payment attempts have been made.
|
// if no payment attempts have been made.
|
||||||
func (m *MissionControl) ResetHistory() error {
|
func (m *MissionControl) ResetHistory() error {
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
if err := m.store.clear(); err != nil {
|
if err := m.store.clear(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -357,8 +357,8 @@ func (m *MissionControl) ResetHistory() error {
|
|||||||
func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
|
func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
|
||||||
amt lnwire.MilliSatoshi, capacity btcutil.Amount) float64 {
|
amt lnwire.MilliSatoshi, capacity btcutil.Amount) float64 {
|
||||||
|
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
now := m.now()
|
now := m.now()
|
||||||
results, _ := m.state.getLastPairResult(fromNode)
|
results, _ := m.state.getLastPairResult(fromNode)
|
||||||
@ -376,8 +376,8 @@ func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
|
|||||||
// GetHistorySnapshot takes a snapshot from the current mission control state
|
// GetHistorySnapshot takes a snapshot from the current mission control state
|
||||||
// and actual probability estimates.
|
// and actual probability estimates.
|
||||||
func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
|
func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
log.Debugf("Requesting history snapshot from mission control")
|
log.Debugf("Requesting history snapshot from mission control")
|
||||||
|
|
||||||
@ -394,8 +394,8 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
|
|||||||
return errors.New("cannot import nil history")
|
return errors.New("cannot import nil history")
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
log.Infof("Importing history snapshot with %v pairs to mission control",
|
log.Infof("Importing history snapshot with %v pairs to mission control",
|
||||||
len(history.Pairs))
|
len(history.Pairs))
|
||||||
@ -411,8 +411,8 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
|
|||||||
func (m *MissionControl) GetPairHistorySnapshot(
|
func (m *MissionControl) GetPairHistorySnapshot(
|
||||||
fromNode, toNode route.Vertex) TimedPairResult {
|
fromNode, toNode route.Vertex) TimedPairResult {
|
||||||
|
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
results, ok := m.state.getLastPairResult(fromNode)
|
results, ok := m.state.getLastPairResult(fromNode)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -478,8 +478,8 @@ func (m *MissionControl) processPaymentResult(result *paymentResult) (
|
|||||||
// Store complete result in database.
|
// Store complete result in database.
|
||||||
m.store.AddResult(result)
|
m.store.AddResult(result)
|
||||||
|
|
||||||
m.Lock()
|
m.mu.Lock()
|
||||||
defer m.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
// Apply result to update mission control state.
|
// Apply result to update mission control state.
|
||||||
reason := m.applyPaymentResult(result)
|
reason := m.applyPaymentResult(result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user