Skip to content

Commit 28a828a

Browse files
committed
routing: unexport MissionControl mutex
Only the MissionControl instance should use this variable and it should not be accessible to users of MissionControl.
1 parent 6b449a6 commit 28a828a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

routing/missioncontrol.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ type MissionControl struct {
121121
// mission control state is updated.
122122
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
123123

124-
sync.Mutex
124+
mu sync.Mutex
125125

126126
// TODO(roasbeef): further counters, if vertex continually unavailable,
127127
// add to another generation
@@ -295,8 +295,8 @@ func (m *MissionControl) init() error {
295295
// with. All fields are copied by value, so we do not need to worry about
296296
// mutation.
297297
func (m *MissionControl) GetConfig() *MissionControlConfig {
298-
m.Lock()
299-
defer m.Unlock()
298+
m.mu.Lock()
299+
defer m.mu.Unlock()
300300

301301
return &MissionControlConfig{
302302
Estimator: m.estimator,
@@ -317,8 +317,8 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
317317
return err
318318
}
319319

320-
m.Lock()
321-
defer m.Unlock()
320+
m.mu.Lock()
321+
defer m.mu.Unlock()
322322

323323
log.Infof("Active mission control cfg: %v, estimator: %v", cfg,
324324
cfg.Estimator)
@@ -338,8 +338,8 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
338338
// ResetHistory resets the history of MissionControl returning it to a state as
339339
// if no payment attempts have been made.
340340
func (m *MissionControl) ResetHistory() error {
341-
m.Lock()
342-
defer m.Unlock()
341+
m.mu.Lock()
342+
defer m.mu.Unlock()
343343

344344
if err := m.store.clear(); err != nil {
345345
return err
@@ -357,8 +357,8 @@ func (m *MissionControl) ResetHistory() error {
357357
func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
358358
amt lnwire.MilliSatoshi, capacity btcutil.Amount) float64 {
359359

360-
m.Lock()
361-
defer m.Unlock()
360+
m.mu.Lock()
361+
defer m.mu.Unlock()
362362

363363
now := m.now()
364364
results, _ := m.state.getLastPairResult(fromNode)
@@ -376,8 +376,8 @@ func (m *MissionControl) GetProbability(fromNode, toNode route.Vertex,
376376
// GetHistorySnapshot takes a snapshot from the current mission control state
377377
// and actual probability estimates.
378378
func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
379-
m.Lock()
380-
defer m.Unlock()
379+
m.mu.Lock()
380+
defer m.mu.Unlock()
381381

382382
log.Debugf("Requesting history snapshot from mission control")
383383

@@ -394,8 +394,8 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
394394
return errors.New("cannot import nil history")
395395
}
396396

397-
m.Lock()
398-
defer m.Unlock()
397+
m.mu.Lock()
398+
defer m.mu.Unlock()
399399

400400
log.Infof("Importing history snapshot with %v pairs to mission control",
401401
len(history.Pairs))
@@ -411,8 +411,8 @@ func (m *MissionControl) ImportHistory(history *MissionControlSnapshot,
411411
func (m *MissionControl) GetPairHistorySnapshot(
412412
fromNode, toNode route.Vertex) TimedPairResult {
413413

414-
m.Lock()
415-
defer m.Unlock()
414+
m.mu.Lock()
415+
defer m.mu.Unlock()
416416

417417
results, ok := m.state.getLastPairResult(fromNode)
418418
if !ok {
@@ -478,8 +478,8 @@ func (m *MissionControl) processPaymentResult(result *paymentResult) (
478478
// Store complete result in database.
479479
m.store.AddResult(result)
480480

481-
m.Lock()
482-
defer m.Unlock()
481+
m.mu.Lock()
482+
defer m.mu.Unlock()
483483

484484
// Apply result to update mission control state.
485485
reason := m.applyPaymentResult(result)

0 commit comments

Comments
 (0)