p2p/disconnection/
mod.rs

1mod p2p_disconnection_state;
2pub use p2p_disconnection_state::*;
3
4mod p2p_disconnection_actions;
5pub use p2p_disconnection_actions::*;
6
7mod p2p_disconnection_reducer;
8
9use serde::{Deserialize, Serialize};
10
11use crate::{
12    channels::{rpc::P2pRpcKind, streaming_rpc::P2pStreamingRpcKind, ChannelId},
13    connection::RejectionReason,
14};
15
16#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, thiserror::Error)]
17pub enum P2pDisconnectionReason {
18    #[error("random disconnection in order to free up space so that more peers can connect")]
19    FreeUpSpace,
20    #[error("message is unexpected for channel {0}")]
21    P2pChannelMsgUnexpected(ChannelId),
22    #[error("failed to send message to channel: {0}")]
23    P2pChannelSendFailed(String),
24    #[error("failed to receive message from channel: {0}")]
25    P2pChannelReceiveFailed(String),
26    #[error("channel {0} is closed")]
27    P2pChannelClosed(ChannelId),
28    #[error("connection is rejected: {0}")]
29    Libp2pIncomingRejected(RejectionReason),
30    #[error("transition frontier RPC({0:?}) timeout")]
31    TransitionFrontierRpcTimeout(P2pRpcKind),
32    #[error("transition frontier streaming RPC({0:?}) timeout")]
33    TransitionFrontierStreamingRpcTimeout(P2pStreamingRpcKind),
34    #[error("received num accounts rejected")]
35    TransitionFrontierSyncLedgerSnarkedNumAccountsRejected,
36    #[error("failed to verify snark pool diff")]
37    SnarkPoolVerifyError,
38    #[error("duplicate connection")]
39    DuplicateConnection,
40    #[error("timeout")]
41    Timeout,
42    #[error("rpc protocol not supported")]
43    Unsupported,
44    #[error("invalid pubsub message")]
45    InvalidMessage,
46}