This commit is contained in:
hinto.janai 2025-01-17 15:22:01 -05:00
parent 416efcb788
commit 2c32e0238e
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
5 changed files with 32 additions and 17 deletions

View file

@ -166,33 +166,32 @@ async fn get_hashes(
mut state: CupratedRpcHandler, mut state: CupratedRpcHandler,
request: GetHashesRequest, request: GetHashesRequest,
) -> Result<GetHashesResponse, Error> { ) -> Result<GetHashesResponse, Error> {
let GetHashesRequest {
start_height,
block_ids,
} = request;
// FIXME: impl `last()` // FIXME: impl `last()`
let last = { let last = {
let len = request.block_ids.len(); let len = block_ids.len();
if len == 0 { if len == 0 {
return Err(anyhow!("block_ids empty")); return Err(anyhow!("block_ids empty"));
} }
request.block_ids[len - 1] block_ids[len - 1]
}; };
let GetHashesRequest {
start_height,
block_ids,
..
} = request;
let hashes: Vec<[u8; 32]> = (&block_ids).into(); let hashes: Vec<[u8; 32]> = (&block_ids).into();
let (m_block_ids, current_height) = let (m_blocks_ids, current_height) =
blockchain::next_chain_entry(&mut state.blockchain_read, hashes, start_height).await?; blockchain::next_chain_entry(&mut state.blockchain_read, hashes, start_height).await?;
Ok(GetHashesResponse { Ok(GetHashesResponse {
base: helper::access_response_base(false), base: helper::access_response_base(false),
m_blocks_ids, m_blocks_ids: m_blocks_ids.into(),
current_height: usize_to_u64(current_height),
start_height, start_height,
current_height,
}) })
} }

View file

@ -328,7 +328,7 @@ async fn is_key_image_spent(
KeyImageSpentStatus::SpentInBlockchain => None, KeyImageSpentStatus::SpentInBlockchain => None,
KeyImageSpentStatus::SpentInPool => unreachable!(), KeyImageSpentStatus::SpentInPool => unreachable!(),
}) })
.collect(); .collect::<Vec<[u8; 32]>>();
// Check if the remaining unspent key images exist in the transaction pool. // Check if the remaining unspent key images exist in the transaction pool.
if !key_images.is_empty() { if !key_images.is_empty() {
@ -346,7 +346,7 @@ async fn is_key_image_spent(
let spent_status = spent_status let spent_status = spent_status
.into_iter() .into_iter()
.map(|status| status.to_u8()) .map(KeyImageSpentStatus::to_u8)
.collect(); .collect();
Ok(IsKeyImageSpentResponse { Ok(IsKeyImageSpentResponse {

View file

@ -123,7 +123,7 @@ pub async fn find_block(
pub async fn next_chain_entry( pub async fn next_chain_entry(
blockchain_read: &mut BlockchainReadHandle, blockchain_read: &mut BlockchainReadHandle,
block_hashes: Vec<[u8; 32]>, block_hashes: Vec<[u8; 32]>,
len: usize, start_height: u64,
) -> Result<(Vec<[u8; 32]>, usize), Error> { ) -> Result<(Vec<[u8; 32]>, usize), Error> {
let BlockchainResponse::NextChainEntry { let BlockchainResponse::NextChainEntry {
block_ids, block_ids,
@ -132,7 +132,10 @@ pub async fn next_chain_entry(
} = blockchain_read } = blockchain_read
.ready() .ready()
.await? .await?
.call(BlockchainReadRequest::NextChainEntry(block_hashes, len)) .call(BlockchainReadRequest::NextChainEntry(
block_hashes,
u64_to_usize(start_height),
))
.await? .await?
else { else {
unreachable!(); unreachable!();

View file

@ -136,11 +136,11 @@ pub async fn key_images_spent_vec(
key_images: Vec<[u8; 32]>, key_images: Vec<[u8; 32]>,
include_sensitive_txs: bool, include_sensitive_txs: bool,
) -> Result<Vec<bool>, Error> { ) -> Result<Vec<bool>, Error> {
let TxpoolReadResponse::KeyImagesSpent(status) = txpool_read let TxpoolReadResponse::KeyImagesSpentVec(status) = txpool_read
.ready() .ready()
.await .await
.map_err(|e| anyhow!(e))? .map_err(|e| anyhow!(e))?
.call(TxpoolReadRequest::KeyImagesSpent { .call(TxpoolReadRequest::KeyImagesSpentVec {
key_images, key_images,
include_sensitive_txs, include_sensitive_txs,
}) })

View file

@ -89,6 +89,10 @@ fn map_request(
key_images, key_images,
include_sensitive_txs, include_sensitive_txs,
} => key_images_spent(env, key_images, include_sensitive_txs), } => key_images_spent(env, key_images, include_sensitive_txs),
TxpoolReadRequest::KeyImagesSpentVec {
key_images,
include_sensitive_txs,
} => key_images_spent_vec(env, key_images, include_sensitive_txs),
TxpoolReadRequest::Pool { TxpoolReadRequest::Pool {
include_sensitive_txs, include_sensitive_txs,
} => pool(env, include_sensitive_txs), } => pool(env, include_sensitive_txs),
@ -252,6 +256,15 @@ fn txs_by_hash(
/// [`TxpoolReadRequest::KeyImagesSpent`]. /// [`TxpoolReadRequest::KeyImagesSpent`].
fn key_images_spent( fn key_images_spent(
env: &ConcreteEnv,
key_images: HashSet<[u8; 32]>,
include_sensitive_txs: bool,
) -> ReadResponseResult {
Ok(TxpoolReadResponse::KeyImagesSpent(todo!()))
}
/// [`TxpoolReadRequest::KeyImagesSpentVec`].
fn key_images_spent_vec(
env: &ConcreteEnv, env: &ConcreteEnv,
key_images: Vec<[u8; 32]>, key_images: Vec<[u8; 32]>,
include_sensitive_txs: bool, include_sensitive_txs: bool,