lnd/routing/probability_estimator.go
bitromortac b8c6227383
routing: add probability estimator interface
We introduce a probability `Estimator` interface which is implemented by
the current apriori probability estimator. A second implementation, the
bimodal probability estimator follows.
2023-02-10 09:58:40 +01:00

38 lines
1.1 KiB
Go

package routing
import (
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
)
// Estimator estimates the probability to reach a node.
type Estimator interface {
// PairProbability estimates the probability of successfully traversing
// to toNode based on historical payment outcomes for the from node.
// Those outcomes are passed in via the results parameter.
PairProbability(now time.Time, results NodeResults,
toNode route.Vertex, amt lnwire.MilliSatoshi,
capacity btcutil.Amount) float64
// LocalPairProbability estimates the probability of successfully
// traversing our own local channels to toNode.
LocalPairProbability(now time.Time, results NodeResults,
toNode route.Vertex) float64
// Config returns the estimator's configuration.
Config() estimatorConfig
// String returns the string representation of the estimator's
// configuration.
String() string
}
// estimatorConfig represents a configuration for a probability estimator.
type estimatorConfig interface {
// validate checks that all configuration parameters are sane.
validate() error
}