txpool: all_hashes

This commit is contained in:
hinto.janai 2024-12-18 21:03:40 -05:00
parent 21e42c1f54
commit ed8de29504
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
3 changed files with 35 additions and 0 deletions

View file

@ -178,6 +178,27 @@ pub async fn pool_stats(
Ok(txpool_stats) Ok(txpool_stats)
} }
/// TODO
pub async fn all_hashes(
txpool_read: &mut TxpoolReadHandle,
include_sensitive_txs: bool,
) -> Result<Vec<[u8; 32]>, Error> {
let TxpoolReadResponse::AllHashes(hashes) = txpool_read
.ready()
.await
.map_err(|e| anyhow!(e))?
.call(TxpoolReadRequest::AllHashes {
include_sensitive_txs,
})
.await
.map_err(|e| anyhow!(e))?
else {
unreachable!();
};
Ok(hashes)
}
/// TODO /// TODO
pub async fn flush(txpool_manager: &mut Infallible, tx_hashes: Vec<[u8; 32]>) -> Result<(), Error> { pub async fn flush(txpool_manager: &mut Infallible, tx_hashes: Vec<[u8; 32]>) -> Result<(), Error> {
todo!(); todo!();

View file

@ -73,6 +73,9 @@ pub enum TxpoolReadRequest {
/// TODO /// TODO
PoolStats { include_sensitive_txs: bool }, PoolStats { include_sensitive_txs: bool },
/// TODO
AllHashes { include_sensitive_txs: bool },
} }
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse //---------------------------------------------------------------------------------------------------- TxpoolReadResponse
@ -130,6 +133,9 @@ pub enum TxpoolReadResponse {
/// Response to [`TxpoolReadRequest::PoolStats`]. /// Response to [`TxpoolReadRequest::PoolStats`].
PoolStats(TxpoolStats), PoolStats(TxpoolStats),
/// Response to [`TxpoolReadRequest::AllHashes`].
AllHashes(Vec<[u8; 32]>),
} }
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest

View file

@ -95,6 +95,9 @@ fn map_request(
TxpoolReadRequest::PoolStats { TxpoolReadRequest::PoolStats {
include_sensitive_txs, include_sensitive_txs,
} => pool_stats(env, include_sensitive_txs), } => pool_stats(env, include_sensitive_txs),
TxpoolReadRequest::AllHashes {
include_sensitive_txs,
} => all_hashes(env, include_sensitive_txs),
} }
} }
@ -268,3 +271,8 @@ fn pool(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
fn pool_stats(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult { fn pool_stats(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
Ok(TxpoolReadResponse::PoolStats(todo!())) Ok(TxpoolReadResponse::PoolStats(todo!()))
} }
/// [`TxpoolReadRequest::AllHashes`].
fn all_hashes(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
Ok(TxpoolReadResponse::AllHashes(todo!()))
}