mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 11:39:30 +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,
|
mut state: CupratedRpcHandler,
|
||||||
_: GetTransactionPoolStatsRequest,
|
_: GetTransactionPoolStatsRequest,
|
||||||
) -> Result<GetTransactionPoolStatsResponse, Error> {
|
) -> 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 {
|
Ok(GetTransactionPoolStatsResponse {
|
||||||
base: helper::access_response_base(false),
|
base: helper::access_response_base(false),
|
||||||
..todo!()
|
pool_stats,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ use cuprate_txpool::{
|
||||||
TxEntry,
|
TxEntry,
|
||||||
};
|
};
|
||||||
use cuprate_types::{
|
use cuprate_types::{
|
||||||
rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo},
|
rpc::{PoolInfo, PoolInfoFull, PoolInfoIncremental, PoolTxInfo, TxpoolStats},
|
||||||
TxInPool, TxRelayChecks,
|
TxInPool, TxRelayChecks,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -157,6 +157,27 @@ pub(crate) async fn pool(
|
||||||
Ok((txs, spent_key_images))
|
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
|
/// TODO
|
||||||
pub(crate) async fn flush(
|
pub(crate) async fn flush(
|
||||||
txpool_manager: &mut Infallible,
|
txpool_manager: &mut Infallible,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_types::{
|
use cuprate_types::{
|
||||||
rpc::{PoolInfo, SpentKeyImageInfo, TxInfo},
|
rpc::{PoolInfo, SpentKeyImageInfo, TxInfo, TxpoolStats},
|
||||||
TransactionVerificationData, TxInPool,
|
TransactionVerificationData, TxInPool,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,6 +70,9 @@ pub enum TxpoolReadRequest {
|
||||||
|
|
||||||
/// TODO
|
/// TODO
|
||||||
Pool { include_sensitive_txs: bool },
|
Pool { include_sensitive_txs: bool },
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
PoolStats { include_sensitive_txs: bool },
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
||||||
|
@ -124,6 +127,9 @@ pub enum TxpoolReadResponse {
|
||||||
txs: Vec<TxInfo>,
|
txs: Vec<TxInfo>,
|
||||||
spent_key_images: Vec<SpentKeyImageInfo>,
|
spent_key_images: Vec<SpentKeyImageInfo>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Response to [`TxpoolReadRequest::PoolStats`].
|
||||||
|
PoolStats(TxpoolStats),
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
||||||
|
|
|
@ -92,6 +92,9 @@ fn map_request(
|
||||||
TxpoolReadRequest::Pool {
|
TxpoolReadRequest::Pool {
|
||||||
include_sensitive_txs,
|
include_sensitive_txs,
|
||||||
} => pool(env, 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!(),
|
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