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§

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§