Crate karyon_p2p

Source
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 πŸ”’
endpoint
error πŸ”’
keypair
listener πŸ”’
message πŸ”’
monitor
Responsible for network and system monitoring. Read More
peer πŸ”’
peer_pool πŸ”’
protocol
Defines the protocol trait. Read More
protocols πŸ”’
routing_table πŸ”’
slots πŸ”’
tls_config πŸ”’
version πŸ”’

StructsΒ§

Backend
Backend serves as the central entry point for initiating and managing the P2P network.
Config
the Configuration for the P2P network.
Peer
PeerID
Represents a unique identifier for a peer.
Version
Represents the network version and protocol version used in karyon p2p.

EnumsΒ§

Error
Represents karyon’s p2p Error.

Type AliasesΒ§

ConnRef πŸ”’
ListenerRef πŸ”’
Result