routing: stricter mission control state failure updates

This commit puts a mechanism in place to prevent a failure for a low
amount from being overwritten very soon after by a higher amount
failure.
This commit is contained in:
Joost Jager
2020-03-23 19:59:16 +01:00
parent 6a36ed44f8
commit 1a6b28553a
4 changed files with 91 additions and 9 deletions

View File

@@ -50,6 +50,11 @@ const (
// DefaultAprioriWeight is the default a priori weight. See
// MissionControlConfig for further explanation.
DefaultAprioriWeight = 0.5
// DefaultMinFailureRelaxInterval is the default minimum time that must
// have passed since the previously recorded failure before the failure
// amount may be raised.
DefaultMinFailureRelaxInterval = time.Minute
)
// NodeResults contains previous results from a node to its peers.
@@ -113,6 +118,11 @@ type MissionControlConfig struct {
// results, unless there are none available.
AprioriWeight float64
// MinFailureRelaxInterval is the minimum time that must have passed
// since the previously recorded failure before the failure amount may
// be raised.
MinFailureRelaxInterval time.Duration
// SelfNode is our own pubkey.
SelfNode route.Vertex
}
@@ -188,7 +198,7 @@ func NewMissionControl(db kvdb.Backend, cfg *MissionControlConfig) (
}
mc := &MissionControl{
state: newMissionControlState(),
state: newMissionControlState(cfg.MinFailureRelaxInterval),
now: time.Now,
cfg: cfg,
store: store,