Skip to content

Commit

Permalink
txpool: all_hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed Dec 19, 2024
1 parent 21e42c1 commit ed8de29
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
21 changes: 21 additions & 0 deletions binaries/cuprated/src/rpc/service/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,27 @@ pub async fn pool_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
pub async fn flush(txpool_manager: &mut Infallible, tx_hashes: Vec<[u8; 32]>) -> Result<(), Error> {
todo!();
Expand Down
6 changes: 6 additions & 0 deletions storage/txpool/src/service/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub enum TxpoolReadRequest {

/// TODO
PoolStats { include_sensitive_txs: bool },

/// TODO
AllHashes { include_sensitive_txs: bool },
}

//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
Expand Down Expand Up @@ -130,6 +133,9 @@ pub enum TxpoolReadResponse {

/// Response to [`TxpoolReadRequest::PoolStats`].
PoolStats(TxpoolStats),

/// Response to [`TxpoolReadRequest::AllHashes`].
AllHashes(Vec<[u8; 32]>),
}

//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
Expand Down
8 changes: 8 additions & 0 deletions storage/txpool/src/service/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ fn map_request(
TxpoolReadRequest::PoolStats {
include_sensitive_txs,
} => pool_stats(env, include_sensitive_txs),
TxpoolReadRequest::AllHashes {
include_sensitive_txs,
} => all_hashes(env, include_sensitive_txs),
}
}

Expand Down Expand Up @@ -268,3 +271,8 @@ fn pool(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
fn pool_stats(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
Ok(TxpoolReadResponse::PoolStats(todo!()))
}

/// [`TxpoolReadRequest::AllHashes`].
fn all_hashes(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {
Ok(TxpoolReadResponse::AllHashes(todo!()))
}

0 comments on commit ed8de29

Please sign in to comment.