Crate p2p

source · []
Expand description

Stronghold-P2p

This crate implements a secure P2P-communication layer for Stronghold. It enables permissioned use of remote strongholds for creating services like remote signing. However, while being significantly influenced by Stronghold’s use-case, it is not dependent on the Stronghold crate itself and may be used independently.

Stronghold-P2p is using the libp2p networking framework. On top of libp2p’s protocols for describing how and what data is send through the network, the StrongholdP2p interface provides an additional layer of abstraction and manages the network polling and all interaction in a event loop that runs in a separate task. Futhermore, it integrates a firewall with which rules can be set to restrict requests and/ or ask for dynamic approval before forwarding them.

Modules

Firewall in StrongholdP2p for filtering inbound requests.

A node’s network identity keys.

Macros

Structs

Wrapper of a [mpsc::channel][futures::channel::mpsc::channel] for sending events. On top of the underlying channel it allows configuration of the Sink behaviour if the channel is full.

Active Listener of the local peer.

Representation of a Multiaddr.

Identifier of a peer of the network.

Inbound Request from a remote peer. It is expected that a response will be returned through the response_rx channel, otherwise an OutboundFailure will occur at the remote peer.

The Relay protocol is not supported.

Unique Id for each request. Note: This ID is only local and does not match the request’s ID at the remote peer.

Central interface for listening to the network, establishing connection to remote peers, sending requests Rq and receiving their response Rs.

Builder for new StrongholdP2p.

Enums

Configure how the network should behave in the case that the capacity of the EventChannel is reached. This is relevant in cases when the frequency of messages is larger than the frequency in which the [mpsc::Receiver][futures::channel::mpsc::Receiver] side reads from the stream.

The endpoint roles associated with an established peer-to-peer connection.

Error on establishing a connection.

Error on dialing a peer and establishing a connection.

The possible failures of dialing.

Possible failures occurring in the context of receiving an inbound request and sending a response.

Use existing keypair for authentication on the transport layer.

Error on listening on an address.

Error on listening on a relayed address.

Events happening in the Network. Includes events about connection and listener status as well as potential failures when receiving request-response messages.

Possible failures occurring in the context of sending an outbound request and receiving the response.

Error on the [Transport][libp2p::Transport].

Traits

Implemented on objects that can run a Future in the background.

Trait for the generic request and response messages.

Functions

Assemble a relayed address for the target following the syntax <relay-addr>/p2p/<relay-id>/p2p-circuit/p2p/<target-id>. The address can be used to reach the target peer if they are listening on that relay.

Type Definitions