mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-21 02:04:31 +00:00
fixes
This commit is contained in:
parent
416efcb788
commit
2c32e0238e
5 changed files with 32 additions and 17 deletions
|
@ -166,33 +166,32 @@ async fn get_hashes(
|
|||
mut state: CupratedRpcHandler,
|
||||
request: GetHashesRequest,
|
||||
) -> Result<GetHashesResponse, Error> {
|
||||
let GetHashesRequest {
|
||||
start_height,
|
||||
block_ids,
|
||||
} = request;
|
||||
|
||||
// FIXME: impl `last()`
|
||||
let last = {
|
||||
let len = request.block_ids.len();
|
||||
let len = block_ids.len();
|
||||
|
||||
if len == 0 {
|
||||
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 (m_block_ids, current_height) =
|
||||
let (m_blocks_ids, current_height) =
|
||||
blockchain::next_chain_entry(&mut state.blockchain_read, hashes, start_height).await?;
|
||||
|
||||
Ok(GetHashesResponse {
|
||||
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,
|
||||
current_height,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ async fn is_key_image_spent(
|
|||
KeyImageSpentStatus::SpentInBlockchain => None,
|
||||
KeyImageSpentStatus::SpentInPool => unreachable!(),
|
||||
})
|
||||
.collect();
|
||||
.collect::<Vec<[u8; 32]>>();
|
||||
|
||||
// Check if the remaining unspent key images exist in the transaction pool.
|
||||
if !key_images.is_empty() {
|
||||
|
@ -346,7 +346,7 @@ async fn is_key_image_spent(
|
|||
|
||||
let spent_status = spent_status
|
||||
.into_iter()
|
||||
.map(|status| status.to_u8())
|
||||
.map(KeyImageSpentStatus::to_u8)
|
||||
.collect();
|
||||
|
||||
Ok(IsKeyImageSpentResponse {
|
||||
|
|
|
@ -123,7 +123,7 @@ pub async fn find_block(
|
|||
pub async fn next_chain_entry(
|
||||
blockchain_read: &mut BlockchainReadHandle,
|
||||
block_hashes: Vec<[u8; 32]>,
|
||||
len: usize,
|
||||
start_height: u64,
|
||||
) -> Result<(Vec<[u8; 32]>, usize), Error> {
|
||||
let BlockchainResponse::NextChainEntry {
|
||||
block_ids,
|
||||
|
@ -132,7 +132,10 @@ pub async fn next_chain_entry(
|
|||
} = blockchain_read
|
||||
.ready()
|
||||
.await?
|
||||
.call(BlockchainReadRequest::NextChainEntry(block_hashes, len))
|
||||
.call(BlockchainReadRequest::NextChainEntry(
|
||||
block_hashes,
|
||||
u64_to_usize(start_height),
|
||||
))
|
||||
.await?
|
||||
else {
|
||||
unreachable!();
|
||||
|
|
|
@ -136,11 +136,11 @@ pub async fn key_images_spent_vec(
|
|||
key_images: Vec<[u8; 32]>,
|
||||
include_sensitive_txs: bool,
|
||||
) -> Result<Vec<bool>, Error> {
|
||||
let TxpoolReadResponse::KeyImagesSpent(status) = txpool_read
|
||||
let TxpoolReadResponse::KeyImagesSpentVec(status) = txpool_read
|
||||
.ready()
|
||||
.await
|
||||
.map_err(|e| anyhow!(e))?
|
||||
.call(TxpoolReadRequest::KeyImagesSpent {
|
||||
.call(TxpoolReadRequest::KeyImagesSpentVec {
|
||||
key_images,
|
||||
include_sensitive_txs,
|
||||
})
|
||||
|
|
|
@ -89,6 +89,10 @@ fn map_request(
|
|||
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 {
|
||||
include_sensitive_txs,
|
||||
} => pool(env, include_sensitive_txs),
|
||||
|
@ -252,6 +256,15 @@ fn txs_by_hash(
|
|||
|
||||
/// [`TxpoolReadRequest::KeyImagesSpent`].
|
||||
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,
|
||||
key_images: Vec<[u8; 32]>,
|
||||
include_sensitive_txs: bool,
|
||||
|
|
Loading…
Reference in a new issue