abci/utils/
connection_type.rs

1use tendermint_proto::abci::request::Value as RequestValue;
2
3/// Different types of connections created by tendermint
4#[derive(Debug, Copy, Clone, Eq, PartialEq)]
5pub enum ConnectionType {
6    Unknown,
7    Consensus,
8    Mempool,
9    Info,
10    Snapshot,
11}
12
13impl Default for ConnectionType {
14    fn default() -> Self {
15        Self::Unknown
16    }
17}
18
19impl From<&RequestValue> for ConnectionType {
20    fn from(request_value: &RequestValue) -> Self {
21        match request_value {
22            RequestValue::Echo(_) | RequestValue::Flush(_) => Self::Unknown,
23            RequestValue::InitChain(_)
24            | RequestValue::BeginBlock(_)
25            | RequestValue::DeliverTx(_)
26            | RequestValue::EndBlock(_)
27            | RequestValue::Commit(_) => Self::Consensus,
28            RequestValue::CheckTx(_) => Self::Mempool,
29            RequestValue::Info(_) | RequestValue::SetOption(_) | RequestValue::Query(_) => {
30                Self::Info
31            }
32            RequestValue::ListSnapshots(_)
33            | RequestValue::OfferSnapshot(_)
34            | RequestValue::LoadSnapshotChunk(_)
35            | RequestValue::ApplySnapshotChunk(_) => Self::Snapshot,
36        }
37    }
38}