mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-23 03:59:31 +00:00
/get_transaction_pool_stats
This commit is contained in:
parent
c5abf9bb98
commit
805f475083
4 changed files with 42 additions and 3 deletions
|
@ -517,9 +517,13 @@ async fn get_transaction_pool_stats(
|
|||
mut state: CupratedRpcHandler,
|
||||
_: GetTransactionPoolStatsRequest,
|
||||
) -> Result<GetTransactionPoolStatsResponse, Error> {
|
||||
let include_sensitive_txs = !state.is_restricted();
|
||||
|
||||
let pool_stats = txpool::pool_stats(&mut state.txpool_read, include_sensitive_txs).await?;
|
||||
|
||||
Ok(GetTransactionPoolStatsResponse {
|
||||
base: helper::access_response_base(false),
|
||||
..todo!()
|
||||
pool_stats,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use cuprate_txpool::{
|
|||
TxEntry,
|
||||
};
|
||||
use cuprate_types::{
|
||||
rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo},
|
||||
rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo, TxpoolStats},
|
||||
TxInPool, TxRelayChecks,
|
||||
};
|
||||
|
||||
|
@ -157,6 +157,27 @@ pub(crate) async fn pool(
|
|||
Ok((txs, spent_key_images))
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub(crate) async fn pool_stats(
|
||||
txpool_read: &mut TxpoolReadHandle,
|
||||
include_sensitive_txs: bool,
|
||||
) -> Result<TxpoolStats, Error> {
|
||||
let TxpoolReadResponse::PoolStats(txpool_stats) = txpool_read
|
||||
.ready()
|
||||
.await
|
||||
.map_err(|e| anyhow!(e))?
|
||||
.call(TxpoolReadRequest::PoolStats {
|
||||
include_sensitive_txs,
|
||||
})
|
||||
.await
|
||||
.map_err(|e| anyhow!(e))?
|
||||
else {
|
||||
unreachable!();
|
||||
};
|
||||
|
||||
Ok(txpool_stats)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub(crate) async fn flush(
|
||||
txpool_manager: &mut Infallible,
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
};
|
||||
|
||||
use cuprate_types::{
|
||||
rpc::{PoolInfo, SpentKeyImageInfo, TxInfo},
|
||||
rpc::{PoolInfo, SpentKeyImageInfo, TxInfo, TxpoolStats},
|
||||
TransactionVerificationData, TxInPool,
|
||||
};
|
||||
|
||||
|
@ -70,6 +70,9 @@ pub enum TxpoolReadRequest {
|
|||
|
||||
/// TODO
|
||||
Pool { include_sensitive_txs: bool },
|
||||
|
||||
/// TODO
|
||||
PoolStats { include_sensitive_txs: bool },
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
||||
|
@ -124,6 +127,9 @@ pub enum TxpoolReadResponse {
|
|||
txs: Vec<TxInfo>,
|
||||
spent_key_images: Vec<SpentKeyImageInfo>,
|
||||
},
|
||||
|
||||
/// Response to [`TxpoolReadRequest::PoolStats`].
|
||||
PoolStats(TxpoolStats),
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
||||
|
|
|
@ -92,6 +92,9 @@ fn map_request(
|
|||
TxpoolReadRequest::Pool {
|
||||
include_sensitive_txs,
|
||||
} => pool(env, include_sensitive_txs),
|
||||
TxpoolReadRequest::PoolStats {
|
||||
include_sensitive_txs,
|
||||
} => pool_stats(env, include_sensitive_txs),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,3 +263,8 @@ fn pool(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
|
|||
spent_key_images: todo!(),
|
||||
})
|
||||
}
|
||||
|
||||
/// [`TxpoolReadRequest::PoolStats`].
|
||||
fn pool_stats(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
|
||||
Ok(TxpoolReadResponse::PoolStats(todo!()))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue