Crate cuprate_p2p_core

source
Expand description

§Cuprate P2P Core

This crate is general purpose P2P networking library for working with Monero. This is a low level crate, which means it may seem verbose for a lot of use cases, if you want a crate that handles more of the P2P logic have a look at cuprate-p2p.

§Network Zones

This crate abstracts over network zones, Tor/I2p/clearnet with the NetworkZone trait. Currently only clearnet is implemented: ClearNet.

§Usage

§Connecting to a peer

// The information about our local node.
let our_basic_node_data = BasicNodeData {
    my_port: 0,
    network_id: Network::Mainnet.network_id(),
    peer_id: 0,
    support_flags: PeerSupportFlags::FLUFFY_BLOCKS,
    rpc_port: 0,
    rpc_credits_per_hash: 0,
};

// See [`HandshakerBuilder`] for information about the default values set, they may not be
// appropriate for every use case.
let handshaker = HandshakerBuilder::<ClearNet>::new(our_basic_node_data).build();

// The outbound connector.
let mut connector = Connector::new(handshaker);

// The connection.
let connection = connector
    .oneshot(ConnectRequest {
        addr,
        permit: None,
    })
    .await
    .unwrap();

Re-exports§

Modules§

  • Data structures related to bans.
  • Connection Handles.
  • This module defines PeerRequest and PeerResponse. Cuprate’s P2P crates works by translating network messages into an internal request/response enums, this is easy for levin “requests” and “responses” (admin messages) but takes a bit more work with “notifications” (protocol messages).

Structs§

Enums§

Traits§