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 ¶
const Subsystem = "CHFT"
Subsystem defines the logging code for this subsystem.
Variables ¶
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.
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 ¶
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.