recommend

package
v0.2.13-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package recommend provides recommendations for closing channels with the constraints provided in its close recommendation config. Only open public channels that have been monitored for the configurable minimum monitored time will be considered for closing.

Channels will be assessed based on the following data points: - Uptime ratio - Fee revenue per block capital has been committed for - Incoming volume per block capital has been committed for - Outgoing volume per block capital has been committed for - Total volume per block capital has been committed for

Channels that are outliers within the set of channels that are eligible for close recommendation will be recommended for closure.

Index

Constants

View Source
const Subsystem = "RECM"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var (

	// ErrNoMetric is returned when a close recommendations with no chosen
	// metric is provided.
	ErrNoMetric = errors.New("metric required for close " +
		"recommendations")

	// DefaultOutlierMultiplier is the default value used in close
	// recommendations based on outliers when there is no user provided
	// value.
	DefaultOutlierMultiplier float64 = 3
)

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type CloseRecommendationConfig

type CloseRecommendationConfig struct {
	// ChannelInsights is a function which returns a set of channel insights
	// for our current set of channels.
	ChannelInsights func() ([]*insights.ChannelInfo, error)

	// Metric defines the metric that we will use to provide close
	// recommendations. Calls will fail if no value is provided.
	Metric Metric

	// MinimumMonitored is the minimum amount of time that a channel must
	// have been monitored for before it is considered for closing.
	MinimumMonitored time.Duration
}

CloseRecommendationConfig provides the functions and parameters required to provide close recommendations. This struct holds fields which are common to all recommendation calculation strategies.

type Metric

type Metric int

Metric is an enum which indicate what data point our recommendations should be based on.

const (

	// UptimeMetric bases recommendations on the uptime of the channel's
	// remote peer.
	UptimeMetric Metric

	// RevenueMetric bases recommendations on the revenue that the channel
	// has generated per block that our capital has been committed for.
	RevenueMetric

	// IncomingVolume bases recommendations on the incoming volume that the
	// channel has processed, scaled by funding transaction confirmations.
	IncomingVolume

	// IncomingVolume bases recommendations on the incoming volume that the
	// channel has processed, scaled by funding transaction confirmations.
	OutgoingVolume

	// Volume bases recommendations on the total volume that the
	// channel has processed, scaled by funding transaction confirmations.
	Volume
)

type Recommendation

type Recommendation struct {
	Value          float64
	RecommendClose bool
}

Recommendation provides the value that a close recommendation was based on, and a boolean indicating whether we recommend closing the channel.

type Report

type Report struct {
	// TotalChannels is the number of channels that we have.
	TotalChannels int

	// ConsideredChannels is the number of channels that have been monitored
	// for long enough to be considered for close.
	ConsideredChannels int

	// Recommendations is a map of chanel outpoints to a bool which
	// indicates whether we should close the channel.
	Recommendations map[string]Recommendation
}

Report contains a set of close recommendations and information about the number of channels considered for close.

func OutlierRecommendations

func OutlierRecommendations(cfg *CloseRecommendationConfig,
	outlierMultiplier float64) (*Report, error)

OutlierRecommendations returns recommendations based on whether a value is a lower outlier within its current dataset. It takes an outlier multiplier value which is the number of inter quartile ranges a value should be away from the lower/upper quartile to be considered an outlier. Recommended values are 1.5 for more aggressive recommendations and 3 for more cautious recommendations.

func ThresholdRecommendations

func ThresholdRecommendations(cfg *CloseRecommendationConfig,
	threshold float64) (*Report, error)

ThresholdRecommendations returns a recommendations based on whether a value is below a given threshold.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL