policy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package policy evaluates the set of conditions and requirements set by the node operator that a channel opening request must satisfy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channels

type Channels struct {
	Number           *Range[uint32]      `yaml:"number,omitempty"`
	Capacity         *StatRange[int64]   `yaml:"capacity,omitempty"`
	ZeroBaseFees     *bool               `yaml:"zero_base_fees,omitempty"`
	BlockHeight      *StatRange[uint32]  `yaml:"block_height,omitempty"`
	TimeLockDelta    *StatRange[uint32]  `yaml:"time_lock_delta,omitempty"`
	MinHTLC          *StatRange[int64]   `yaml:"min_htlc,omitempty"`
	MaxHTLC          *StatRange[uint64]  `yaml:"max_htlc,omitempty"`
	LastUpdateDiff   *StatRange[uint32]  `yaml:"last_update_diff,omitempty"`
	Together         *Range[int]         `yaml:"together,omitempty"`
	IncomingFeeRates *StatRange[int64]   `yaml:"incoming_fee_rates,omitempty"`
	OutgoingFeeRates *StatRange[int64]   `yaml:"outgoing_fee_rates,omitempty"`
	IncomingBaseFees *StatRange[int64]   `yaml:"incoming_base_fees,omitempty"`
	OutgoingBaseFees *StatRange[int64]   `yaml:"outgoing_base_fees,omitempty"`
	IncomingDisabled *StatRange[float64] `yaml:"incoming_disabled,omitempty"`
	OutgoingDisabled *StatRange[float64] `yaml:"outgoing_disabled,omitempty"`
}

Channels represents a set of requirements that the initiator's node channels must satisfy.

type Conditions

type Conditions struct {
	IsPrivate     *bool     `yaml:"is_private,omitempty"`
	WantsZeroConf *bool     `yaml:"wants_zero_conf,omitempty"`
	Is            *[]string `yaml:"is,omitempty"`
	IsNot         *[]string `yaml:"is_not,omitempty"`
	Request       *Request  `yaml:"request,omitempty"`
	Node          *Node     `yaml:"node,omitempty"`
}

Conditions represents a set of requirements that must be met to apply a policy.

func (*Conditions) Match

func (c *Conditions) Match(
	req *lnrpc.ChannelAcceptRequest,
	node *lnrpc.GetInfoResponse,
	peer *lnrpc.NodeInfo,
) bool

Match returns true if all the conditions Match.

type Node

type Node struct {
	Age          *Range[uint32]      `yaml:"age,omitempty"`
	Capacity     *Range[int64]       `yaml:"capacity,omitempty"`
	Hybrid       *bool               `yaml:"hybrid,omitempty"`
	FeatureFlags *[]lnrpc.FeatureBit `yaml:"feature_flags,omitempty"`
	Channels     *Channels           `yaml:"channels,omitempty"`
}

Node represents a set of requirements the node requesting to open a channel must satisfy.

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

Number is an integer or float.

type Operation

type Operation string

Operation is a mathematical operation applied to a set of values.

const (
	// Middle value in a list ordered from smallest to largest.
	Median Operation = "median"
	// Average of a list of numbers.
	Mean Operation = "mean"
	// Most frequently occurring value on a list.
	Mode Operation = "mode"
	// Difference between the biggest and the smallest number.
	RangeOp Operation = "range"
)

Operations to measure the central tendency of a data set.

type Policy

type Policy struct {
	Conditions             *Conditions `yaml:"conditions,omitempty"`
	Request                *Request    `yaml:"request,omitempty"`
	Node                   *Node       `yaml:"node,omitempty"`
	AllowList              *[]string   `yaml:"allow_list,omitempty"`
	BlockList              *[]string   `yaml:"block_list,omitempty"`
	ZeroConfList           *[]string   `yaml:"zero_conf_list,omitempty"`
	RejectAll              *bool       `yaml:"reject_all,omitempty"`
	RejectPrivateChannels  *bool       `yaml:"reject_private_channels,omitempty"`
	AcceptZeroConfChannels *bool       `yaml:"accept_zero_conf_channels,omitempty"`
	MinAcceptDepth         *uint32     `yaml:"min_accept_depth,omitempty"`
}

Policy represents a set of requirements that a channel opening request must satisfy. They are enforced only if the conditions are met or do not exist.

func (*Policy) Evaluate

Evaluate set of policies.

type Range

type Range[T Number] struct {
	Min *T `yaml:"min,omitempty"`
	Max *T `yaml:"max,omitempty"`
}

Range represents the limits of a series.

func (Range[T]) Contains

func (r Range[T]) Contains(v T) bool

Contains returns whether the received value is within the range.

func (Range[T]) Reason

func (r Range[T]) Reason() string

Reason returns the reason why a number was not in the range.

type Request

type Request struct {
	ChannelCapacity  *Range[uint64]          `yaml:"channel_capacity,omitempty"`
	ChannelReserve   *Range[uint64]          `yaml:"channel_reserve,omitempty"`
	CSVDelay         *Range[uint32]          `yaml:"csv_delay,omitempty"`
	PushAmount       *Range[uint64]          `yaml:"push_amount,omitempty"`
	MaxAcceptedHTLCs *Range[uint32]          `yaml:"max_accepted_htlcs,omitempty"`
	MinHTLC          *Range[uint64]          `yaml:"min_htlc,omitempty"`
	MaxValueInFlight *Range[uint64]          `yaml:"max_value_in_flight,omitempty"`
	DustLimit        *Range[uint64]          `yaml:"dust_limit,omitempty"`
	CommitmentTypes  *[]lnrpc.CommitmentType `yaml:"commitment_types,omitempty"`
}

Request represents the desired values in a channel request.

type StatRange

type StatRange[T Number] struct {
	Min       *T        `yaml:"min,omitempty"`
	Max       *T        `yaml:"max,omitempty"`
	Operation Operation `yaml:"operation,omitempty"`
}

StatRange is like a range but received multiple values and applies an operation to them.

func (StatRange[T]) Contains

func (a StatRange[T]) Contains(values []T) bool

Contains returns whether the aggregated value is within the range.

func (StatRange[T]) Reason

func (a StatRange[T]) Reason() string

Reason returns the reason why a number was not in the range.

Jump to

Keyboard shortcuts

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