bouncer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChiaExecutableSuffix = "chia-blockchain/venv/bin/chia"

Variables

This section is empty.

Functions

This section is empty.

Types

type Chia

type Chia interface {
	// ListNodes will list all connected FullNodes
	ListNodes() (nodes []FullNode, err error)
	// RemoveNode will remove a connected Full Node by it's nodeId
	RemoveNode(nodeId string) error
}

Chia interface to provide basic actions for Chia

type ChiaCli

type ChiaCli struct {
	// ChiaExecutable represents the chia executable e.g. /home/steffen/chia-blockchain/venv/bin/chia
	ChiaExecutable string
}

ChiaCli represents the chia command line interface

func (ChiaCli) ListNodes

func (c ChiaCli) ListNodes() (nodes []FullNode, err error)

ListNodes will list all connected FullNodes. It basically acts as wrapper around "chia show -c"

func (ChiaCli) RemoveNode

func (c ChiaCli) RemoveNode(nodeId string) error

RemoveNode will remove the connected full node via "chia show -r nodeId"

type Context

type Context struct {
	// ChiaExecutable the chia executable e.g. /home/steffen/chia-blockchain/venv/bin/chia
	ChiaExecutable string
	// Location is the location to filter for
	Location string
	// IsDownThreshold is true in case it was set by the user
	IsDownThreshold bool
	// DownThreshold is the down speed threshold to filter for
	DownThreshold float64
	// Done indicates that we are done (--help, --version...)
	Done bool
}

Context describes the environment of the tool execution

func RunCli

func RunCli() (*Context, error)

RunCli starts the cli which includes validation of parameters. The returned context consists of a chia executable and location to filter for

type ExecCmd

type ExecCmd func(name string, arg ...string) (out []byte, err error)

ExecCmd represents the call to execute a command

type Filter

type Filter interface {
	// Filter certain Fullnodes
	Filter() ([]FullNode, error)
}

Filter acts as base for filtering certain FullNodes

type FilterByDown added in v0.2.0

type FilterByDown struct {
	Nodes []FullNode
	// threshold the minimum (inclusive down speed)
	Threshold float64
}

FilterByDown can filter FullNodes by it's down speed. All Nodes which have a lower or equal down speed than specified by threshold will be present

func (FilterByDown) Filter added in v0.2.0

func (f FilterByDown) Filter() ([]FullNode, error)

Filter performs filtering of FullNodes by down threshold. All Nodes which have a lower or equal down speed than specified by threshold will be present

type FilterByLocation

type FilterByLocation struct {
	Nodes            []FullNode
	LocationToFilter string
}

FilterByLocation can filter FullNodes by it's location

func (FilterByLocation) Filter

func (f FilterByLocation) Filter() ([]FullNode, error)

Filter performs filtering of FullNodes by LocationToFilter. The Filtering is be performed in a case insensitive manner.

type FullNode

type FullNode struct {
	// Ip V4 e.g. 127.0.0.1, 123.11.12.13
	Ip string
	// Ports in format 61075/8444
	Ports string
	// NodeId represents the node id (e.g. aaaabbcc)
	NodeId string
	// LastConnect in format May 14 11:15:20
	LastConnect string
	// Up represents the uplink in MiB
	Up float64
	// Down represents the downlink in MiB
	Down float64
}

FullNode represents a connected full node

func (FullNode) IpLocation

func (f FullNode) IpLocation() (string, error)

IpLocation to get the corresponding location of the ipV4 of the FullNode

type GetLocation

type GetLocation func(ipV4 string) (string, error)

GetLocation to get the Geo Ip Location for a ipV4 Address

type Lookup

type Lookup interface {
	// IpLocation to perform a lookup based on the Geo IP  Location
	IpLocation() (string, error)
}

Lookup interface to perform basic lookups

Jump to

Keyboard shortcuts

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