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.
LeaveNetwork
Unsubscribe from the gossipsub topic for network_id.
Announce
Publish a serialised NodeInfo on the gossipsub topic for network_id.
Fields
AnnounceIndex
Publish a serialised FragmentIndexAnnouncement on the index gossip
topic (billpouch/v1/{network_id}/index) for network_id.
Fields
payload: Vec<u8>Serialised FragmentIndexAnnouncement bytes.
Dial
Dial a remote peer at a known [Multiaddr].
Fields
addr: MultiaddrPushFragment
Push a fragment to a remote Pouch peer for storage.
FetchChunkFragments
Fetch all fragments a remote Pouch holds for a given chunk. The response is sent back through the oneshot channel.
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: MultiaddrPing
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: PeerIdProofOfStorage
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NetworkCommand
impl !RefUnwindSafe for NetworkCommand
impl Send for NetworkCommand
impl Sync for NetworkCommand
impl Unpin for NetworkCommand
impl !UnwindSafe for NetworkCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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