Crate sn_routing[][src]

Peer implementation for a resilient decentralised network infrastructure.

This is the “engine room” of a hybrid p2p network, where the p2p nodes are built on top of this library. The features this library gives us is:

Structs

Cache

A BTreeMap-backed cache supporting capacity- and duration-based expiry.

Config

Routing configuration.

EventStream

Stream of routing node events

Prefix

A section prefix, i.e. a sequence of bits specifying the part of the network’s name space consisting of all names that start with this sequence.

Routing

Interface for sending and receiving messages to and from other nodes, in the role of a full routing node.

SendStream

Stream of outgoing messages

TransportConfig

QuicP2p configurations

XorName

A 256-bit number, viewed as a point in XOR space.

Enums

Error

Internal error.

Event

An Event raised by a Node or Client via its event sender.

NodeElderChange

A flag in EldersChanged event, indicating whether the node got promoted, demoted or did not change.

Constants

ELDER_SIZE

Number of elders per section.

FIRST_SECTION_MAX_AGE

Defines the higher bound of this range.

FIRST_SECTION_MIN_AGE

During the first section, nodes can start at a range of age to avoid too many nodes having the same time get relocated at the same time. Defines the lower bound of this range.

MIN_ADULT_AGE

The minimum age a node becomes an adult node.

MIN_AGE

The minimum age a node can have. The Infants will start at age 4. This is to prevent frequent relocations during the beginning of a node’s lifetime.

RECOMMENDED_SECTION_SIZE

Recommended section size. sn_routing will keep adding nodes until the section reaches this size. More nodes might be added if requested by the upper layers. This number also detemines when split happens - if both post-split sections would have at least this number of nodes.

XOR_NAME_LEN

Constant byte length of XorName.

Traits

PeerUtils
SectionAuthorityProviderUtils

A new SectionAuthorityProvider is created whenever the elders change, due to an elder being added or removed, or the section splitting or merging.

Type Definitions

Result

The type returned by the sn_routing message handling methods.