Trait cuprate_p2p_core::NetworkZone

source ·
pub trait NetworkZone:
    Clone
    + Copy
    + Send
    + 'static {
    type Addr: NetZoneAddress;
    type Stream: Stream<Item = Result<Message, BucketError>> + Unpin + Send + 'static;
    type Sink: Sink<LevinMessage<Message>, Error = BucketError> + Unpin + Send + 'static;
    type Listener: Stream<Item = Result<(Option<Self::Addr>, Self::Stream, Self::Sink), Error>> + Send + 'static;
    type ServerCfg: Clone + Debug + Send + 'static;

    const NAME: &'static str;
    const ALLOW_SYNC: bool;
    const DANDELION_PP: bool;
    const CHECK_NODE_ID: bool;
    const SEEDS: &'static [Self::Addr];

    // Required methods
    fn connect_to_peer<'async_trait>(
        addr: Self::Addr,
    ) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, Self::Sink), Error>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn incoming_connection_listener<'async_trait>(
        config: Self::ServerCfg,
        port: u16,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Listener, Error>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

An abstraction over a network zone (tor/i2p/clear)

Required Associated Constants§

source

const NAME: &'static str

The network name.

source

const ALLOW_SYNC: bool

Allow syncing over this network.

Not recommended for anonymity networks.

source

const DANDELION_PP: bool

Enable dandelion++ for this network.

This is unneeded on anonymity networks.

source

const CHECK_NODE_ID: bool

Check if our node ID matches the incoming peers node ID for this network.

This has privacy implications on an anonymity network if true so should be set to false.

source

const SEEDS: &'static [Self::Addr]

Fixed seed nodes for this network.

Required Associated Types§

source

type Addr: NetZoneAddress

The address type of this network.

source

type Stream: Stream<Item = Result<Message, BucketError>> + Unpin + Send + 'static

The stream (incoming data) type for this network.

source

type Sink: Sink<LevinMessage<Message>, Error = BucketError> + Unpin + Send + 'static

The sink (outgoing data) type for this network.

source

type Listener: Stream<Item = Result<(Option<Self::Addr>, Self::Stream, Self::Sink), Error>> + Send + 'static

The inbound connection listener for this network.

source

type ServerCfg: Clone + Debug + Send + 'static

Config used to start a server which listens for incoming connections.

Required Methods§

source

fn connect_to_peer<'async_trait>( addr: Self::Addr, ) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, Self::Sink), Error>> + Send + 'async_trait>>
where Self: 'async_trait,

Connects to a peer with the given address.

This does not complete a handshake with the peer, to do that see the crate docs.

Returns the Self::Stream and Self::Sink to send messages to the peer.

source

fn incoming_connection_listener<'async_trait>( config: Self::ServerCfg, port: u16, ) -> Pin<Box<dyn Future<Output = Result<Self::Listener, Error>> + Send + 'async_trait>>
where Self: 'async_trait,

Object Safety§

This trait is not object safe.

Implementors§