cmpb/
txpool.rs

1/// TxPoolSignal is used by tx pool to send signal to block proposer
2#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct TxPoolSignal {
5    /// transaction event type
6    #[prost(enumeration = "SignalType", tag = "1")]
7    pub signal_type: i32,
8    /// chainId
9    #[prost(string, tag = "2")]
10    pub chain_id: ::prost::alloc::string::String,
11}
12/// TxPoolStatus defines txPool status
13#[allow(clippy::derive_partial_eq_without_eq)]
14#[derive(Clone, PartialEq, ::prost::Message)]
15pub struct TxPoolStatus {
16    /// the max size of config tx pool
17    #[prost(int32, tag = "1")]
18    pub config_tx_pool_size: i32,
19    /// the max size of common tx pool
20    #[prost(int32, tag = "2")]
21    pub common_tx_pool_size: i32,
22    /// the num of config tx in queue cache
23    #[prost(int32, tag = "3")]
24    pub config_tx_num_in_queue: i32,
25    /// the num of config tx in pending cache
26    #[prost(int32, tag = "4")]
27    pub config_tx_num_in_pending: i32,
28    /// the num of common tx in queue cache
29    #[prost(int32, tag = "5")]
30    pub common_tx_num_in_queue: i32,
31    /// the num of common tx in pending cache
32    #[prost(int32, tag = "6")]
33    pub common_tx_num_in_pending: i32,
34}
35/// TxPoolMsg contains all txPool msg type and msg body
36#[allow(clippy::derive_partial_eq_without_eq)]
37#[derive(Clone, PartialEq, ::prost::Message)]
38pub struct TxPoolMsg {
39    /// txPool message type
40    #[prost(enumeration = "TxPoolMsgType", tag = "1")]
41    pub r#type: i32,
42    /// message bytes
43    #[prost(bytes = "vec", tag = "2")]
44    pub payload: ::prost::alloc::vec::Vec<u8>,
45}
46/// transaction batch, used to add transaction efficiently in normal and batch txPool
47#[allow(clippy::derive_partial_eq_without_eq)]
48#[derive(Clone, PartialEq, ::prost::Message)]
49pub struct TxBatch {
50    /// batch id = timestamp(8byte)+nodeId(8byte)+batchHash(8byte)
51    #[prost(string, tag = "1")]
52    pub batch_id: ::prost::alloc::string::String,
53    /// batch size
54    #[prost(int32, tag = "3")]
55    pub size: i32,
56    /// transaction list
57    #[prost(message, repeated, tag = "4")]
58    pub txs: ::prost::alloc::vec::Vec<super::common::Transaction>,
59    /// Map: transaction ID mapping record( key: transaction ID, value: transaction index in txs)
60    #[prost(map = "string, int32", tag = "5")]
61    pub tx_ids_map: ::std::collections::HashMap<::prost::alloc::string::String, i32>,
62    /// batch signature
63    #[prost(message, optional, tag = "6")]
64    pub endorsement: ::core::option::Option<super::common::EndorsementEntry>,
65}
66/// transaction recover request, used to request transactions from proposer
67#[allow(clippy::derive_partial_eq_without_eq)]
68#[derive(Clone, PartialEq, ::prost::Message)]
69pub struct TxRecoverRequest {
70    /// node id
71    #[prost(string, tag = "1")]
72    pub node_id: ::prost::alloc::string::String,
73    /// height
74    #[prost(uint64, tag = "2")]
75    pub height: u64,
76    /// txId list
77    #[prost(string, repeated, tag = "3")]
78    pub tx_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
79}
80/// transaction recover response, used to return transactions to the validators by proposer
81#[allow(clippy::derive_partial_eq_without_eq)]
82#[derive(Clone, PartialEq, ::prost::Message)]
83pub struct TxRecoverResponse {
84    /// node id
85    #[prost(string, tag = "1")]
86    pub node_id: ::prost::alloc::string::String,
87    /// height
88    #[prost(uint64, tag = "2")]
89    pub height: u64,
90    /// tx list
91    #[prost(message, repeated, tag = "3")]
92    pub txs: ::prost::alloc::vec::Vec<super::common::Transaction>,
93}
94/// batch recover request, used to request batch from proposer
95#[allow(clippy::derive_partial_eq_without_eq)]
96#[derive(Clone, PartialEq, ::prost::Message)]
97pub struct TxBatchRecoverRequest {
98    /// proposer node id
99    #[prost(string, tag = "1")]
100    pub node_id: ::prost::alloc::string::String,
101    /// height
102    #[prost(uint64, tag = "2")]
103    pub height: u64,
104    /// batchId list
105    #[prost(string, repeated, tag = "3")]
106    pub batch_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
107}
108/// batch recover response, used to return transactions to the validators by proposer
109#[allow(clippy::derive_partial_eq_without_eq)]
110#[derive(Clone, PartialEq, ::prost::Message)]
111pub struct TxBatchRecoverResponse {
112    /// node id
113    #[prost(string, tag = "1")]
114    pub node_id: ::prost::alloc::string::String,
115    /// height
116    #[prost(uint64, tag = "2")]
117    pub height: u64,
118    /// batch list
119    #[prost(message, repeated, tag = "3")]
120    pub tx_batches: ::prost::alloc::vec::Vec<TxBatch>,
121}
122/// rpc get pool status request
123#[allow(clippy::derive_partial_eq_without_eq)]
124#[derive(Clone, PartialEq, ::prost::Message)]
125pub struct GetPoolStatusRequest {
126    /// blockchain identifier
127    #[prost(string, tag = "1")]
128    pub chain_id: ::prost::alloc::string::String,
129}
130/// rpc get tx ids by type and stage request
131#[allow(clippy::derive_partial_eq_without_eq)]
132#[derive(Clone, PartialEq, ::prost::Message)]
133pub struct GetTxIdsByTypeAndStageRequest {
134    /// blockchain identifier
135    #[prost(string, tag = "1")]
136    pub chain_id: ::prost::alloc::string::String,
137    /// tx type
138    #[prost(enumeration = "TxType", tag = "2")]
139    pub tx_type: i32,
140    /// tx stage
141    #[prost(enumeration = "TxStage", tag = "3")]
142    pub tx_stage: i32,
143}
144/// rpc get tx ids by type and stage response
145#[allow(clippy::derive_partial_eq_without_eq)]
146#[derive(Clone, PartialEq, ::prost::Message)]
147pub struct GetTxIdsByTypeAndStageResponse {
148    /// tx id list
149    #[prost(string, repeated, tag = "1")]
150    pub tx_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
151}
152/// rpc get txs in pool by tx ids request
153#[allow(clippy::derive_partial_eq_without_eq)]
154#[derive(Clone, PartialEq, ::prost::Message)]
155pub struct GetTxsInPoolByTxIdsRequest {
156    /// blockchain identifier
157    #[prost(string, tag = "1")]
158    pub chain_id: ::prost::alloc::string::String,
159    /// tx id list
160    #[prost(string, repeated, tag = "2")]
161    pub tx_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
162}
163/// rpc get txs in pool by tx ids response
164#[allow(clippy::derive_partial_eq_without_eq)]
165#[derive(Clone, PartialEq, ::prost::Message)]
166pub struct GetTxsInPoolByTxIdsResponse {
167    /// txs in the tx pool
168    #[prost(message, repeated, tag = "1")]
169    pub txs: ::prost::alloc::vec::Vec<super::common::Transaction>,
170    /// tx ids of txs that are not in the tx pool
171    #[prost(string, repeated, tag = "2")]
172    pub tx_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
173}
174/// SignalType is a transaction event type
175#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
176#[repr(i32)]
177pub enum SignalType {
178    /// no transaction
179    NoEvent = 0,
180    /// new transaction
181    TransactionIncome = 1,
182    /// packing block
183    BlockPropose = 2,
184}
185impl SignalType {
186    /// String value of the enum field names used in the ProtoBuf definition.
187    ///
188    /// The values are not transformed in any way and thus are considered stable
189    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
190    pub fn as_str_name(&self) -> &'static str {
191        match self {
192            SignalType::NoEvent => "NO_EVENT",
193            SignalType::TransactionIncome => "TRANSACTION_INCOME",
194            SignalType::BlockPropose => "BLOCK_PROPOSE",
195        }
196    }
197    /// Creates an enum from field names used in the ProtoBuf definition.
198    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
199        match value {
200            "NO_EVENT" => Some(Self::NoEvent),
201            "TRANSACTION_INCOME" => Some(Self::TransactionIncome),
202            "BLOCK_PROPOSE" => Some(Self::BlockPropose),
203            _ => None,
204        }
205    }
206}
207/// TxType is the transaction type
208#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
209#[repr(i32)]
210pub enum TxType {
211    /// unknown
212    UnknownType = 0,
213    /// config transaction
214    ConfigTx = 1,
215    /// common transaction
216    CommonTx = 2,
217    /// config and common transaction
218    AllType = 3,
219}
220impl TxType {
221    /// String value of the enum field names used in the ProtoBuf definition.
222    ///
223    /// The values are not transformed in any way and thus are considered stable
224    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
225    pub fn as_str_name(&self) -> &'static str {
226        match self {
227            TxType::UnknownType => "UNKNOWN_TYPE",
228            TxType::ConfigTx => "CONFIG_TX",
229            TxType::CommonTx => "COMMON_TX",
230            TxType::AllType => "ALL_TYPE",
231        }
232    }
233    /// Creates an enum from field names used in the ProtoBuf definition.
234    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
235        match value {
236            "UNKNOWN_TYPE" => Some(Self::UnknownType),
237            "CONFIG_TX" => Some(Self::ConfigTx),
238            "COMMON_TX" => Some(Self::CommonTx),
239            "ALL_TYPE" => Some(Self::AllType),
240            _ => None,
241        }
242    }
243}
244/// TxStage is the current transaction stage
245#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
246#[repr(i32)]
247pub enum TxStage {
248    /// unknown
249    UnknownStage = 0,
250    ///   in queue
251    InQueue = 1,
252    /// in pending
253    InPending = 2,
254    /// in queue and in pending
255    AllStage = 3,
256}
257impl TxStage {
258    /// String value of the enum field names used in the ProtoBuf definition.
259    ///
260    /// The values are not transformed in any way and thus are considered stable
261    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
262    pub fn as_str_name(&self) -> &'static str {
263        match self {
264            TxStage::UnknownStage => "UNKNOWN_STAGE",
265            TxStage::InQueue => "IN_QUEUE",
266            TxStage::InPending => "IN_PENDING",
267            TxStage::AllStage => "ALL_STAGE",
268        }
269    }
270    /// Creates an enum from field names used in the ProtoBuf definition.
271    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
272        match value {
273            "UNKNOWN_STAGE" => Some(Self::UnknownStage),
274            "IN_QUEUE" => Some(Self::InQueue),
275            "IN_PENDING" => Some(Self::InPending),
276            "ALL_STAGE" => Some(Self::AllStage),
277            _ => None,
278        }
279    }
280}
281/// TxPoolMsgType defines different type message in txPool
282#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
283#[repr(i32)]
284pub enum TxPoolMsgType {
285    /// single transaction type
286    SingleTx = 0,
287    /// batch transaction type
288    BatchTx = 1,
289    /// transaction recover request type
290    RecoverReq = 2,
291    /// transaction recover response type
292    RecoverResp = 3,
293}
294impl TxPoolMsgType {
295    /// String value of the enum field names used in the ProtoBuf definition.
296    ///
297    /// The values are not transformed in any way and thus are considered stable
298    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
299    pub fn as_str_name(&self) -> &'static str {
300        match self {
301            TxPoolMsgType::SingleTx => "SINGLE_TX",
302            TxPoolMsgType::BatchTx => "BATCH_TX",
303            TxPoolMsgType::RecoverReq => "RECOVER_REQ",
304            TxPoolMsgType::RecoverResp => "RECOVER_RESP",
305        }
306    }
307    /// Creates an enum from field names used in the ProtoBuf definition.
308    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
309        match value {
310            "SINGLE_TX" => Some(Self::SingleTx),
311            "BATCH_TX" => Some(Self::BatchTx),
312            "RECOVER_REQ" => Some(Self::RecoverReq),
313            "RECOVER_RESP" => Some(Self::RecoverResp),
314            _ => None,
315        }
316    }
317}