chanfitness

package
v0.9.1-beta.rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package chanfitness monitors the behaviour of channels to provide insight into the health and performance of a channel. This is achieved by maintaining an event store which tracks events for each channel.

Lifespan: the period that the channel has been known to the scoring system. Note that lifespan may not equal the channel's full lifetime because data is not currently persisted.

Uptime: the total time within a given period that the channel's remote peer has been online.

Index

Constants

View Source
const Subsystem = "CHFT"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var (

	// ErrChannelNotFound is returned when a query is made for a channel that
	// the event store does not have knowledge of.
	ErrChannelNotFound = errors.New("channel not found in event store")
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

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 ChannelEventStore

type ChannelEventStore struct {
	// contains filtered or unexported fields
}

ChannelEventStore maintains a set of event logs for the node's channels to provide insight into the performance and health of channels.

func NewChannelEventStore

func NewChannelEventStore(config *Config) *ChannelEventStore

NewChannelEventStore initializes an event store with the config provided. Note that this function does not start the main event loop, Start() must be called.

func (*ChannelEventStore) GetLifespan

func (c *ChannelEventStore) GetLifespan(
	channelPoint wire.OutPoint) (time.Time, time.Time, error)

GetLifespan returns the opening and closing time observed for a channel and a boolean to indicate whether the channel is known the the event store. If the channel is still open, a zero close time is returned.

func (*ChannelEventStore) GetUptime

func (c *ChannelEventStore) GetUptime(channelPoint wire.OutPoint, startTime,
	endTime time.Time) (time.Duration, error)

GetUptime returns the uptime of a channel over a period and an error if the channel cannot be found or the uptime calculation fails.

func (*ChannelEventStore) Start

func (c *ChannelEventStore) Start() error

Start adds all existing open channels to the event store and starts the main loop which records channel and peer events, and serves requests for information from the store. If this function fails, it cancels its existing subscriptions and returns an error.

func (*ChannelEventStore) Stop

func (c *ChannelEventStore) Stop()

Stop terminates all goroutines started by the event store.

type Config

type Config struct {
	// SubscribeChannelEvents provides a subscription client which provides a
	// stream of channel events.
	SubscribeChannelEvents func() (*subscribe.Client, error)

	// SubscribePeerEvents provides a subscription client which provides a
	// stream of peer online/offline events.
	SubscribePeerEvents func() (*subscribe.Client, error)

	// GetOpenChannels provides a list of existing open channels which is used
	// to populate the ChannelEventStore with a set of channels on startup.
	GetOpenChannels func() ([]*channeldb.OpenChannel, error)
}

Config provides the event store with functions required to monitor channel activity. All elements of the config must be non-nil for the event store to operate.

Jump to

Keyboard shortcuts

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