fc_rpc_core/txpool.rs
1// This file is part of Frontier.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! tx pool rpc interface
20
21use ethereum_types::U256;
22use jsonrpsee::{core::RpcResult, proc_macros::rpc};
23
24use crate::types::*;
25
26/// TxPool rpc interface
27#[rpc(server)]
28pub trait TxPoolApi {
29 /// The content inspection property can be queried to list the exact details of all the
30 /// transactions currently pending for inclusion in the next block(s), as well as the ones that
31 /// are being scheduled for future execution only.
32 ///
33 /// The result is an object with two fields pending and queued. Each of these fields are
34 /// associative arrays, in which each entry maps an origin-address to a batch of scheduled
35 /// transactions. These batches themselves are maps associating nonces with actual transactions.
36 ///
37 /// For details, see [txpool_content (geth)](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content)
38 /// or [txpool_content (nethermind)](https://docs.nethermind.io/nethermind/ethereum-client/json-rpc/txpool#txpool_content).
39 #[method(name = "txpool_content")]
40 fn content(&self) -> RpcResult<TxPoolResult<TransactionMap<Transaction>>>;
41
42 /// The inspect inspection property can be queried to list a textual summary of all the
43 /// transactions currently pending for inclusion in the next block(s), as well as the ones that
44 /// are being scheduled for future execution only. This is a method specifically tailored to
45 /// developers to quickly see the transactions in the pool and find any potential issues.
46 ///
47 /// The result is an object with two fields pending and queued. Each of these fields are
48 /// associative arrays, in which each entry maps an origin-address to a batch of scheduled
49 /// transactions. These batches themselves are maps associating nonces with transactions
50 /// summary strings.
51 ///
52 /// For details, see [txpool_inspect (geth)](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect)
53 /// or [txpool_inspect (nethermind)](https://docs.nethermind.io/nethermind/ethereum-client/json-rpc/txpool#txpool_inspect).
54 #[method(name = "txpool_inspect")]
55 fn inspect(&self) -> RpcResult<TxPoolResult<TransactionMap<Summary>>>;
56
57 /// The status inspection property can be queried for the number of transactions currently
58 /// pending for inclusion in the next block(s), as well as the ones that are being scheduled
59 /// for future execution only.
60 ///
61 /// The result is an object with two fields pending and queued, each of which is a counter
62 /// representing the number of transactions in that particular state.
63 ///
64 /// For details, see [txpool_status (geth)](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-status)
65 /// or [txpool_status (nethermind)](https://docs.nethermind.io/nethermind/ethereum-client/json-rpc/txpool#txpool_status).
66 #[method(name = "txpool_status")]
67 fn status(&self) -> RpcResult<TxPoolResult<U256>>;
68}