mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-31 02:01:46 +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.
|
||||
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
||||
|
||||
sync.Mutex
|
||||
mu sync.Mutex
|
||||
|
||||
// TODO(roasbeef): further counters, if vertex continually unavailable,
|
||||
// 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
|
||||
// mutation.
|
||||
func (m *MissionControl) GetConfig() *MissionControlConfig {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
return &MissionControlConfig{
|
||||
Estimator: m.estimator,
|
||||
@ -317,8 +317,8 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
|
||||
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
|
||||
// if no payment attempts have been made.
|
||||
func (m *MissionControl) ResetHistory() error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
if err := m.store.clear(); err != nil {
|
||||
return err
|
||||
@ -357,8 +357,8 @@ func (m *MissionControl) ResetHistory() error {
|
||||
func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
|
||||
amt lnwire.MilliSatoshi, capacity btcutil.Amount) float64 {
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
now := m.now()
|
||||
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
|
||||
// and actual probability estimates.
|
||||
func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
log.Infof("Importing history snapshot with %v pairs to mission control",
|
||||
len(history.Pairs))
|
||||
@ -411,8 +411,8 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
|
||||
func (m *MissionControl) GetPairHistorySnapshot(
|
||||
fromNode, toNode route.Vertex) TimedPairResult {
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
results, ok := m.state.getLastPairResult(fromNode)
|
||||
if !ok {
|
||||
@ -478,8 +478,8 @@ func (m *MissionControl) processPaymentResult(result *paymentResult) (
|
||||
// Store complete result in database.
|
||||
m.store.AddResult(result)
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
// Apply result to update mission control state.
|
||||
reason := m.applyPaymentResult(result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user