Expand description
A lightweight, extensible, and customizable peer-to-peer (p2p) network stack.
Β§Example
use std::sync::Arc;
use easy_parallel::Parallel;
use smol::{future, Executor};
use karyon_p2p::{Backend, Config, PeerID, keypair::{KeyPair, KeyPairType}};
// Generate a new keypair for the peer
let key_pair = KeyPair::generate(&KeyPairType::Ed25519);
// Create the configuration for the backend.
let mut config = Config::default();
// Create a new Executor
let ex = Arc::new(Executor::new());
// Create a new Backend
let backend = Backend::new(&key_pair, config, ex.clone().into());
let task = async {
// Run the backend
backend.run()
.await
.expect("start the backend");
// ....
// Shutdown the backend
backend.shutdown().await;
};
future::block_on(ex.run(task));
Modules§
- backend π
- codec π
- config π
- conn_
queue π - connection π
- connector π
- discovery π
- error π
- listener π
- message π
- Responsible for network and system monitoring.
Read More
- peer π
- peer_
pool π - Defines the protocol trait.
Read More
- protocols π
- routing_
table π - slots π
- tls_
config π - version π
Structs§
- Backend serves as the central entry point for initiating and managing the P2P network.
- the Configuration for the P2P network.
- Represents a unique identifier for a peer.
- Represents the network version and protocol version used in karyon p2p.
Enums§
- Represents karyonβs p2p Error.
Type Aliases§
- ConnRef π
- Listener
Ref π