Crate floresta_wire

Source
Expand description

§Floresta Wire

This crate provides the core networking logic for a full node using libfloresta, including the P2P network and the mempool. You can easily integrate it with any other crate that provides a BlockchainInterface and UpdatableChainstate implementation.

A node also gives you a handle that you can use to send messages to the node, like requesting blocks, mempool transactions or asking to connect with a given peer.

Modules§

address_manNon-WebAssembly
Address manager is a module that keeps track of known peer addresses and associated metadata. This module is very important in keeping our node protected against targeted attacks, like eclipse attacks.
chain_selectorNon-WebAssembly
A module that connects with multiple peers and finds the best chain.
mempoolNon-WebAssembly
A simple mempool that keeps our transactions in memory. It try to rebroadcast our transactions every 1 hour. Once our transaction is included in a block, we remove it from the mempool.
nodeNon-WebAssembly
Main file for this blockchain. A node is the central task that runs and handles important events, such as new blocks, peer connection/disconnection, new addresses, etc. A node should not care about peer-specific messages, peers’ll handle things like pings.
node_contextNon-WebAssembly
During the lifetime of a Bitcoin client, we have a couple of phases that are slightly different from each other, having to implement their own state-machines and logic for handing requests. While we could simply put everything in one struct and have a single impl block, that would create a massive amount of if’s in the code, taking different paths depending on which state are we in. For that reason, we define the basics of a node, like code shared by all the states into one base struct called UtreexoNode, we then further refine this struct using fine-tuned Contexts, that should implement NodeContext and are passed-in as a generic parameter by the caller.
node_interfaceNon-WebAssembly
node_interface, which holds NodeInterface and related methods that define the API to interact with the floresta node
running_nodeNon-WebAssembly
After a node catches-up with the network, we can start listening for new blocks, handing any request our user might make and keep our peers alive. This mode requires way less bandwidth and CPU to run, being bound by the number of blocks found in a given period.
sync_nodeNon-WebAssembly
A node that downloads and validates the blockchain.

Structs§

UtreexoNodeConfigNon-WebAssembly
Configuration for the Utreexo node.

Traits§

NodeHooks
NodeHooks is a trait that defines the hooks that a node can use to interact with the network and the blockchain. Every time an event happens, the node will call the corresponding hook.