cfx_rpc_cfx_api/
debug.rs

1// Copyright 2019 Conflux Foundation. All rights reserved.
2// Conflux is free software and distributed under GNU General Public License.
3// See http://www.gnu.org/licenses/
4
5use cfx_rpc_cfx_types::{
6    ConsensusGraphStates, EpochNumber, RpcAddress, StatOnGasLoad,
7    SyncGraphStates, Transaction as RpcTransaction,
8};
9use cfx_rpc_eth_types::WrapTransaction;
10use cfx_types::{H256, U64};
11// use cfxcore::verification::EpochReceiptProof;
12use jsonrpsee::{core::RpcResult as JsonRpcResult, proc_macros::rpc};
13use network::{
14    node_table::{Node, NodeId},
15    throttling, SessionDetails, UpdateNodeOperation,
16};
17use std::collections::BTreeMap;
18
19#[rpc(server, namespace = "debug")]
20pub trait DebugRpc {
21    #[method(name = "inspectTxPool")]
22    fn txpool_inspect(
23        &self, address: Option<RpcAddress>,
24    ) -> JsonRpcResult<
25        BTreeMap<String, BTreeMap<String, BTreeMap<usize, Vec<String>>>>,
26    >;
27
28    // return all txpool transactions grouped by hex address
29    #[method(name = "txPoolContent")]
30    fn txpool_content(
31        &self, address: Option<RpcAddress>,
32    ) -> JsonRpcResult<
33        BTreeMap<
34            String,
35            BTreeMap<String, BTreeMap<usize, Vec<RpcTransaction>>>,
36        >,
37    >;
38
39    // return account ready + deferred transactions
40    #[method(name = "txPoolAccountTransactions")]
41    fn txpool_get_account_transactions(
42        &self, address: RpcAddress,
43    ) -> JsonRpcResult<Vec<RpcTransaction>>;
44
45    #[method(name = "clearTxPool")]
46    fn txpool_clear(&self) -> JsonRpcResult<()>;
47
48    #[method(name = "getNetThrottling")]
49    fn net_throttling(&self) -> JsonRpcResult<throttling::Service>;
50
51    #[method(name = "getNetNode")]
52    fn net_node(
53        &self, node_id: NodeId,
54    ) -> JsonRpcResult<Option<(String, Node)>>;
55
56    #[method(name = "disconnectNetNode")]
57    fn net_disconnect_node(
58        &self, id: NodeId, op: Option<UpdateNodeOperation>,
59    ) -> JsonRpcResult<bool>;
60
61    #[method(name = "getNetSessions")]
62    fn net_sessions(
63        &self, node_id: Option<NodeId>,
64    ) -> JsonRpcResult<Vec<SessionDetails>>;
65
66    #[method(name = "currentSyncPhase")]
67    fn current_sync_phase(&self) -> JsonRpcResult<String>;
68
69    #[method(name = "consensusGraphState")]
70    fn consensus_graph_state(&self) -> JsonRpcResult<ConsensusGraphStates>;
71
72    #[method(name = "syncGraphState")]
73    fn sync_graph_state(&self) -> JsonRpcResult<SyncGraphStates>;
74
75    #[method(name = "statOnGasLoad")]
76    fn stat_on_gas_load(
77        &self, last_epoch: EpochNumber, time_window: U64,
78    ) -> JsonRpcResult<Option<StatOnGasLoad>>;
79
80    // #[method(name = "getEpochReceiptProofByTransaction")]
81    // fn epoch_receipt_proof_by_transaction(
82    //     &self, tx_hash: H256,
83    // ) -> JsonRpcResult<Option<EpochReceiptProof>>;
84
85    #[method(name = "getTransactionsByEpoch")]
86    fn transactions_by_epoch(
87        &self, epoch_number: U64,
88    ) -> JsonRpcResult<Vec<WrapTransaction>>;
89
90    #[method(name = "getTransactionsByBlock")]
91    fn transactions_by_block(
92        &self, block_hash: H256,
93    ) -> JsonRpcResult<Vec<WrapTransaction>>;
94}