From 8b7bef4f485e306935c97e9e282460949fbafa47 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 3 Oct 2022 15:18:22 +0200 Subject: [PATCH] feat: add debug functions --- crates/net/rpc-api/src/debug.rs | 27 +++++++++++++++++++++++++++ crates/net/rpc-api/src/lib.rs | 5 +++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 crates/net/rpc-api/src/debug.rs diff --git a/crates/net/rpc-api/src/debug.rs b/crates/net/rpc-api/src/debug.rs new file mode 100644 index 000000000..d70bebcc1 --- /dev/null +++ b/crates/net/rpc-api/src/debug.rs @@ -0,0 +1,27 @@ +use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc}; +use reth_primitives::{BlockId, Bytes, H256}; +use reth_rpc_types::RichBlock; + +/// Debug rpc interface. +#[rpc(server)] +pub trait DebugApi { + /// Returns an RLP-encoded header. + #[method(name = "debug_getRawHeader")] + async fn raw_header(&self, block_id: BlockId) -> Result; + + /// Returns an RLP-encoded block. + #[method(name = "debug_getRawBlock")] + async fn raw_block(&self, block_id: BlockId) -> Result; + + /// Returns a EIP-2718 binary-encoded transaction. + #[method(name = "debug_getRawTransaction")] + async fn raw_transaction(&self, hash: H256) -> Result; + + /// Returns an array of EIP-2718 binary-encoded receipts. + #[method(name = "debug_getRawReceipts")] + async fn raw_receipts(&self, block_id: BlockId) -> Result>; + + /// Returns an array of recent bad blocks that the client has seen on the network. + #[method(name = "debug_getRawReceipts")] + async fn bad_blocks(&self) -> Result>; +} diff --git a/crates/net/rpc-api/src/lib.rs b/crates/net/rpc-api/src/lib.rs index 76c59ac99..24a7d3615 100644 --- a/crates/net/rpc-api/src/lib.rs +++ b/crates/net/rpc-api/src/lib.rs @@ -9,6 +9,7 @@ //! //! Provides all RPC interfaces. +mod debug; mod eth; mod eth_filter; mod eth_pubsub; @@ -17,6 +18,6 @@ mod trace; mod web3; pub use self::{ - eth::EthApiServer, eth_filter::EthFilterApiServer, eth_pubsub::EthPubSubApiServer, - net::NetApiServer, web3::Web3ApiServer, + debug::DebugApiServer, eth::EthApiServer, eth_filter::EthFilterApiServer, + eth_pubsub::EthPubSubApiServer, net::NetApiServer, web3::Web3ApiServer, };