From a10ed59201b1cad2e1b88171de3e85a55776fd8d Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Mon, 14 Oct 2024 20:43:24 -0400 Subject: [PATCH] get_transaction_pool_backlog --- binaries/cuprated/src/rpc/json.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs index 146cface..e9cd80c3 100644 --- a/binaries/cuprated/src/rpc/json.rs +++ b/binaries/cuprated/src/rpc/json.rs @@ -41,7 +41,7 @@ use cuprate_rpc_types::{ SetBansRequest, SetBansResponse, SubmitBlockRequest, SubmitBlockResponse, SyncInfoRequest, SyncInfoResponse, }, - misc::{BlockHeader, ChainInfo, GetBan, HardforkEntry, HistogramEntry, Status}, + misc::{BlockHeader, ChainInfo, GetBan, HardforkEntry, HistogramEntry, Status, TxBacklogEntry}, CORE_RPC_VERSION, }; @@ -680,12 +680,22 @@ async fn sync_info( /// async fn get_transaction_pool_backlog( - state: CupratedRpcHandler, + mut state: CupratedRpcHandler, request: GetTransactionPoolBacklogRequest, ) -> Result { + let backlog = txpool::backlog(&mut state.txpool_read) + .await? + .into_iter() + .map(|entry| TxBacklogEntry { + weight: entry.weight, + fee: entry.fee, + time_in_pool: entry.time_in_pool.as_secs(), + }) + .collect(); + Ok(GetTransactionPoolBacklogResponse { base: ResponseBase::OK, - backlog: todo!(), + backlog, }) }