Crate pchain_network

source ·
Expand description

Implementation of ParallelChain protocol peer-to-peer (P2P) networking.

§Starting a peer

use crate::configuration::Config; 
use crate::messages::MessageGateChain;
use crate::engine;
use crate::network::{SendCommand, NetworkTopic};
 
// 1. Build a configuration.
let config = Config::new();
 
// 2. Create message gate chain. 
let gates = MessageGateChain::new()
// .chain(message_gate1) 
// .chain(message_gate2)
// ...
 
// 3. Start P2P network.
let network = engine::start(config, vec![], gates).await.unwrap();
 
// 4. Send out messages.
let sender = network.sender();
let _ = sender.send(SendCommand::Broadcast(NetworkTopic::new("topic".to_string()), Vec::new())).await;

Modules§

  • Configuration parameters provided by the library user.
  • start a ParallelChain Network peer. This is the entrypoint to to this library.
  • Messages that can be sent using Gossipsub, as well as chainable “gates” to process them on receipt.
  • Network, the handle type you use to send messages.
  • Information which identifies a peer (PeerInfo).