$$ \newcommand \Peer {\mathrm{Peer}} \newcommand \Tag {\mathrm{tag}} $$
Network Definitions
Let us define a general GossipNode
pseudo interface, which implements a set of
methods that should be available in any network layer to provide all required
functionalities.
-
Start()
Initializes the network by setting up all required data structures, peer connections, and listeners. -
Stop()
Shuts down the network, closing all connections and performing garbage collection. -
Address() -> string
Computes the address of the caller node, inside the specified network structure, according to the network layer addressing (see the addressing section). -
Broadcast(tag protocolTag, data []byte, wait bool, except Peer)
Builds a message and sends a packet of data and protocol \( \Tag \) to all connected peers. Conceptually, it only excludes itself, although it could exclude any specific \( \Peer \) using theexcept
parameter. Ifwait
is active, the call blocks until the send is complete (allowing for synchronous message sending). -
Relay(tag protocol.Tag, data []byte, wait bool, except Peer)
Similar toBroadcast
, but semantically intended for message forwarding. Theexcept
parameter explicitly identifies the message’s original sender, ensuring the data is not relayed back to its source. This distinction is useful when implementing relay logic, where the sender is extracted from the raw message metadata, if present. In special cases, when a node simulates the reception of its own message for internal processing, self-exclusion is bypassed, and the node includes itself in the relaying logic. This helps ensure protocol components receive their own outputs when needed.
⚙️ IMPLEMENTATION
Relay reference implementation
-
Disconnect(badnode Peer)
Forces disconnection from the givenbadnode
\( \Peer \). -
RequestConnectOutgoing(replace bool)
Initiates outgoing connections to new \( \Peer \), with the option toreplace
the existing managed peer connections. -
OnNetworkAdvance()
Notifies the network layer that the Agreement protocol has made significant progress. While network health monitoring can detect message flow, it cannot ensure protocol-level advancement. A node may reside within a fast, densely connected but isolated partition, receiving messages quickly but missing those from outside. Therefore, this function is triggered whenever the Agreement protocol observes a certification-bundle or at least a proposal-value for a new block, allowing the node to confidently infer that the network is not partitioned.
⚙️ IMPLEMENTATION
Usage of
OnNetworkAdvace
in reference implementation
GetGenesisID() -> string
Returns the network-specificgenesisID
, a string indicating the kind of network this node is connected to (see the Ledger normative section for further details on this field).