fc_rpc_v2_api/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
19use ethereum_types::Address;
20use jsonrpsee::{core::RpcResult, proc_macros::rpc};
21
22use crate::types::txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolStatus};
23
24/// TxPool RPC interface.
25#[rpc(client, server, namespace = "txpool")]
26#[async_trait]
27pub trait TxPoolApi {
28 /// The content inspection property can be queried to list the exact details of all the
29 /// transactions currently pending for inclusion in the next block(s), as well as the ones that
30 /// are being scheduled for future execution only.
31 ///
32 /// The result is an object with two fields pending and queued. Each of these fields are
33 /// associative arrays, in which each entry maps an origin-address to a batch of scheduled
34 /// transactions. These batches themselves are maps associating nonces with actual transactions.
35 ///
36 /// Refer to [txpool_content](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-content).
37 #[method(name = "content")]
38 async fn content(&self) -> RpcResult<TxpoolContent>;
39
40 /// Retrieves the transactions contained within the txpool, returning pending as well as queued
41 /// transactions of this address, grouped by nonce.
42 ///
43 /// Refer to [txpool_contentFrom](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-contentfrom).
44 #[method(name = "contentFrom")]
45 async fn content_from(&self, address: Address) -> RpcResult<TxpoolContentFrom>;
46
47 /// The inspect inspection property can be queried to list a textual summary of all the
48 /// transactions currently pending for inclusion in the next block(s), as well as the ones that
49 /// are being scheduled for future execution only. This is a method specifically tailored to
50 /// developers to quickly see the transactions in the pool and find any potential issues.
51 ///
52 /// The result is an object with two fields pending and queued. Each of these fields are
53 /// associative arrays, in which each entry maps an origin-address to a batch of scheduled
54 /// transactions. These batches themselves are maps associating nonces with transactions
55 /// summary strings.
56 ///
57 /// Refer to [txpool_inspect](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-inspect).
58 #[method(name = "inspect")]
59 async fn inspect(&self) -> RpcResult<TxpoolInspect>;
60
61 /// The status inspection property can be queried for the number of transactions currently
62 /// pending for inclusion in the next block(s), as well as the ones that are being scheduled
63 /// for future execution only.
64 ///
65 /// The result is an object with two fields pending and queued, each of which is a counter
66 /// representing the number of transactions in that particular state.
67 ///
68 /// Refer to [txpool_status](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool#txpool-status).
69 #[method(name = "status")]
70 async fn status(&self) -> RpcResult<TxpoolStatus>;
71}