Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

$$ \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 the except parameter. If wait 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 to Broadcast, but semantically intended for message forwarding. The except 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 given badnode \( \Peer \).

  • RequestConnectOutgoing(replace bool)
    Initiates outgoing connections to new \( \Peer \), with the option to replace 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-specific genesisID, a string indicating the kind of network this node is connected to (see the Ledger normative section for further details on this field).