Module hosts

Module hosts 

Source
Expand description

Hosts are a list of network addresses used when establishing outbound connections.

Hosts are shared across the network through the address protocol. When attempting to connect, a node will loop through addresses in the hosts store until it finds ones to connect to. The main interface for interacting with the hostlist. Contains the following:

Hosts: the main parent class that manages HostRegistry and HostContainer. It is also responsible for filtering addresses before writing to the hostlist.

HostRegistry: A locked HashMap that maps peer addresses onto mutually exclusive states (HostState). Prevents race conditions by dictating a strict flow of logically acceptable states.

HostContainer: A wrapper for the hostlists. Each hostlist is represented by a HostColor, which can be Grey, White, Gold or Black. Exposes a common interface for hostlist queries and utilities.

HostColor:

White: Hosts that have passed the GreylistRefinery successfully.

Gold: Hosts we have been able to establish a connection to in OutboundSession.

Grey: Recently received hosts that are checked by the GreylistRefinery and upgraded to the whitelist if valid. If they’re inaccessible by the Refinery they will be deleted.

Black: hostile hosts that are strictly avoided for the duration of the program.

Dark: hosts that do not match our transports, but that we continue to share with other peers. We do not keep darklist entries that are older than one day. This is to avoid peers propagating nodes that may be faulty. We assume that within the one day period, the nodes will be picked up by peers that accept the transports and can refine them to remove inactive peers. Dark list hosts are otherwise ignored.

HostState: a set of mutually exclusive states that can be Insert, Refine, Connect, Suspend or Connected. The state is None when the corresponding host has been removed from the HostRegistry.

Structs§

HostContainer
A Container for managing Grey, White, Gold and Black hostlists. Exposes a common interface for writing to and querying hostlists.
Hosts
Main parent class for the management and manipulation of hostlists.

Enums§

HostColor
HostState 🔒
HostState is a set of mutually exclusive states that can be Insert, Refine, Move, Connect, Suspend or Connected or Free.

Constants§

DARKLIST_MAX_LEN 🔒
GREYLIST_MAX_LEN 🔒
LOCAL_HOST_STRS
WHITELIST_MAX_LEN 🔒

Traits§

UnstableFeatureIp 🔒
We need a convenience method from Rust’s unstable feature “ip”. When https://github.com/rust-lang/rust/issues/27709 is stablized we can remove this.

Type Aliases§

HostRegistry 🔒
Keeps track of hosts and their current state. Prevents race conditions where multiple threads are simultaneously trying to change the state of a given host.
HostsPtr
Atomic pointer to hosts object