routing: add string method for cfg

This commit is contained in:
carla 2021-01-19 10:57:11 +02:00
parent 0735d359b9
commit 97442da8f7
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -1,6 +1,7 @@
package routing package routing
import ( import (
"fmt"
"sync" "sync"
"time" "time"
@ -125,6 +126,15 @@ type MissionControlConfig struct {
MinFailureRelaxInterval time.Duration MinFailureRelaxInterval time.Duration
} }
// String returns a string representation of a mission control config.
func (c *MissionControlConfig) String() string {
return fmt.Sprintf("Penalty Half Life: %v, Apriori Hop "+
"Probablity: %v, Maximum History: %v, Apriori Weight: %v, "+
"Minimum Failure Relax Interval: %v", c.PenaltyHalfLife,
c.AprioriHopProbability, c.MaxMcHistory, c.AprioriWeight,
c.MinFailureRelaxInterval)
}
// TimedPairResult describes a timestamped pair result. // TimedPairResult describes a timestamped pair result.
type TimedPairResult struct { type TimedPairResult struct {
// FailTime is the time of the last failure. // FailTime is the time of the last failure.
@ -178,10 +188,7 @@ type paymentResult struct {
func NewMissionControl(db kvdb.Backend, self route.Vertex, func NewMissionControl(db kvdb.Backend, self route.Vertex,
cfg *MissionControlConfig) (*MissionControl, error) { cfg *MissionControlConfig) (*MissionControl, error) {
log.Debugf("Instantiating mission control with config: "+ log.Debugf("Instantiating mission control with config: %v", cfg)
"PenaltyHalfLife=%v, AprioriHopProbability=%v, "+
"AprioriWeight=%v", cfg.PenaltyHalfLife,
cfg.AprioriHopProbability, cfg.AprioriWeight)
store, err := newMissionControlStore(db, cfg.MaxMcHistory) store, err := newMissionControlStore(db, cfg.MaxMcHistory)
if err != nil { if err != nil {