NetworkCommand

Enum NetworkCommand 

Source
pub enum NetworkCommand {
    JoinNetwork {
        network_id: String,
    },
    LeaveNetwork {
        network_id: String,
    },
    Announce {
        network_id: String,
        payload: Vec<u8>,
    },
    AnnounceIndex {
        network_id: String,
        payload: Vec<u8>,
    },
    Dial {
        addr: Multiaddr,
    },
    PushFragment {
        peer_id: PeerId,
        chunk_id: String,
        fragment_id: String,
        data: Vec<u8>,
    },
    FetchChunkFragments {
        peer_id: PeerId,
        chunk_id: String,
        resp_tx: Sender<FragmentResponse>,
    },
    Shutdown,
    DialRelay {
        relay_addr: Multiaddr,
    },
    Ping {
        peer_id: PeerId,
        sent_at_ms: u64,
        resp_tx: Sender<u64>,
    },
    ProofOfStorage {
        peer_id: PeerId,
        chunk_id: String,
        fragment_id: String,
        nonce: u64,
        resp_tx: Sender<bool>,
    },
}
Expand description

Commands the daemon can send to the network task over the [mpsc] channel.

The network loop runs inside a dedicated tokio::spawned task and receives these commands via the cmd_rx half of the channel created in run_daemon.

Variants§

§

JoinNetwork

Subscribe to the gossipsub topic for network_id.

Fields

§network_id: String
§

LeaveNetwork

Unsubscribe from the gossipsub topic for network_id.

Fields

§network_id: String
§

Announce

Publish a serialised NodeInfo on the gossipsub topic for network_id.

Fields

§network_id: String

Network whose topic to publish on.

§payload: Vec<u8>

Serialised NodeInfo bytes.

§

AnnounceIndex

Publish a serialised FragmentIndexAnnouncement on the index gossip topic (billpouch/v1/{network_id}/index) for network_id.

Fields

§network_id: String

Network whose index topic to publish on.

§payload: Vec<u8>

Serialised FragmentIndexAnnouncement bytes.

§

Dial

Dial a remote peer at a known [Multiaddr].

Fields

§addr: Multiaddr
§

PushFragment

Push a fragment to a remote Pouch peer for storage.

Fields

§peer_id: PeerId
§chunk_id: String
§fragment_id: String
§data: Vec<u8>
§

FetchChunkFragments

Fetch all fragments a remote Pouch holds for a given chunk. The response is sent back through the oneshot channel.

Fields

§peer_id: PeerId
§chunk_id: String
§resp_tx: Sender<FragmentResponse>
§

Shutdown

Ask the network loop to exit cleanly.

§

DialRelay

Dial a relay node and create a circuit reservation.

After a successful reservation the node becomes reachable at /p2p-circuit addresses routed through the relay, enabling connectivity even when behind symmetric NAT.

Fields

§relay_addr: Multiaddr
§

Ping

Ping a remote peer for RTT measurement.

The network loop sends a FragmentRequest::Ping, waits for the FragmentResponse::Pong, computes the RTT in milliseconds and forwards it to resp_tx. On timeout or failure the sender is dropped without sending.

Fields

§peer_id: PeerId
§sent_at_ms: u64

Monotonic timestamp (ms) at send time — used to compute RTT.

§resp_tx: Sender<u64>

Receives rtt_ms when the Pong arrives.

§

ProofOfStorage

Issue a Proof-of-Storage challenge to a remote Pouch.

The network loop sends FragmentRequest::ProofOfStorage, awaits a FragmentResponse::ProofOfStorageOk, and delivers true (proof received) or false (no response / fragment not found) to resp_tx.

Fields

§peer_id: PeerId
§chunk_id: String
§fragment_id: String
§nonce: u64
§resp_tx: Sender<bool>

Receives true if a proof was returned, false otherwise.

Trait Implementations§

Source§

impl Debug for NetworkCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more