autopilot: introduce NodeMetric interface for arbitrary graph metrics

This commit adds the NodeMetric interface which will be used for all
graph metrics not directly part of the autopilot but are useful in
composite heuristics to drive autopilot decisions and improve node
scores.
This commit is contained in:
Andras Banki-Horvath 2019-12-20 12:52:08 +01:00
parent 9bf117a0f2
commit be83d504f8

@ -147,6 +147,23 @@ type AttachmentHeuristic interface {
map[NodeID]*NodeScore, error)
}
// NodeMetric is a common interface for all graph metrics that are not
// directly used as autopilot node scores but may be used in compositional
// heuristics or statistical information exposed to users.
type NodeMetric interface {
// Name returns the unique name of this metric.
Name() string
// Refresh refreshes the metric values based on the current graph.
Refresh(graph ChannelGraph) error
// GetMetric returns the latest value of this metric. Values in the
// map are per node and can be in arbitrary domain. If normalize is
// set to true, then the returned values are normalized to either
// [0, 1] or [-1, 1] depending on the metric.
GetMetric(normalize bool) map[NodeID]float64
}
// ScoreSettable is an interface that indicates that the scores returned by the
// heuristic can be mutated by an external caller. The ExternalScoreAttachment
// currently implements this interface, and so should any heuristic that is