flush_transaction_pool

This commit is contained in:
hinto.janai 2024-10-14 18:01:16 -04:00
parent c7ae795837
commit 6af977f0a5
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
2 changed files with 11 additions and 6 deletions

View file

@ -48,6 +48,8 @@ use crate::rpc::{
CupratedRpcHandler,
};
use super::request::txpool;
/// Map a [`JsonRpcRequest`] to the function that will lead to a [`JsonRpcResponse`].
pub(super) async fn map_request(
state: CupratedRpcHandler,
@ -497,7 +499,14 @@ async fn flush_transaction_pool(
state: CupratedRpcHandler,
request: FlushTransactionPoolRequest,
) -> Result<FlushTransactionPoolResponse, Error> {
todo!();
let tx_hashes = request
.txids
.into_iter()
.map(helper::hex_to_hash)
.collect::<Result<Vec<[u8; 32]>, _>>()?;
txpool::flush(tx_hashes).await?;
Ok(FlushTransactionPoolResponse { status: Status::Ok })
}

View file

@ -49,11 +49,7 @@ pub(crate) async fn size(txpool_read: &mut TxpoolReadHandle) -> Result<u64, Erro
}
/// TODO
#[expect(clippy::needless_pass_by_ref_mut, reason = "TODO: remove after impl")]
pub(crate) async fn flush(
txpool_read: &mut TxpoolReadHandle,
tx_hashes: Vec<[u8; 32]>,
) -> Result<(), Error> {
pub(crate) async fn flush(tx_hashes: Vec<[u8; 32]>) -> Result<(), Error> {
todo!();
Ok(())
}