fix(RPC): Encode hashmap as list for transmission

In commit 1096a293 on neptune-core, the return type of RPC endpoint
`addition_records_for_block` changes from `HashMap` to `Vec`. This
commit applies the matching change on the side of the client,
including building the original hashmap from the transmitted list.

These commits (the present one and the one referenced) fix the issue
that transparent transaction info could not be transferred across the
RPC layer.
This commit is contained in:
Alan Szepieniec 2025-08-23 00:57:00 +02:00
parent 847e4f1e3d
commit 817835302b
4 changed files with 17 additions and 11 deletions

2
Cargo.lock generated
View File

@ -1737,7 +1737,7 @@ dependencies = [
[[package]] [[package]]
name = "neptune-cash" name = "neptune-cash"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/Neptune-Crypto/neptune-core.git?branch=asz%2Ftransparent-transactions#cece8dab9db0334b07a2112a9163e3882ab71a55" source = "git+https://github.com/Neptune-Crypto/neptune-core.git?branch=master#1096a2935af9c023a3a737638c09195f4801881b"
dependencies = [ dependencies = [
"aead", "aead",
"aes-gcm", "aes-gcm",

View File

@ -48,7 +48,7 @@ arbitrary = "1.4.1"
proptest-arbitrary-interop = "0.1.0" proptest-arbitrary-interop = "0.1.0"
[patch.crates-io] [patch.crates-io]
neptune-cash = { git = "https://github.com/Neptune-Crypto/neptune-core.git", branch = "asz/transparent-transactions" } neptune-cash = { git = "https://github.com/Neptune-Crypto/neptune-core.git", branch = "master" }
[features] [features]
mock = ["dep:blake3", "dep:rand"] mock = ["dep:blake3", "dep:rand"]

View File

@ -84,12 +84,19 @@ pub async fn announcement_page(
.iter() .iter()
.map(|output| output.addition_record()) .map(|output| output.addition_record())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
addition_record_indices = state.rpc_client.addition_record_indices_for_block(context::current(), state.token(), block_selector, &addition_records).await addition_record_indices = state
.rpc_client
.addition_record_indices_for_block(
context::current(),
state.token(),
block_selector,
&addition_records,
)
.await
.map_err(|e| not_found_html_response(state, Some(e.to_string())))? .map_err(|e| not_found_html_response(state, Some(e.to_string())))?
.map_err(rpc_method_err)? .map_err(rpc_method_err)?
.expect( .into_iter()
"block guaranteed to exist because we got here; getting its announcements should work", .collect::<HashMap<_, _>>();
);
let mut transparent_utxos_cache = state.transparent_utxos_cache.lock().await; let mut transparent_utxos_cache = state.transparent_utxos_cache.lock().await;

View File

@ -19,7 +19,6 @@ use neptune_cash::rpc_server::error::RpcError;
use neptune_cash::rpc_server::RPCClient; use neptune_cash::rpc_server::RPCClient;
use neptune_cash::rpc_server::RpcResult; use neptune_cash::rpc_server::RpcResult;
use neptune_cash::util_types::mutator_set::addition_record::AdditionRecord; use neptune_cash::util_types::mutator_set::addition_record::AdditionRecord;
use std::collections::HashMap;
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use std::net::SocketAddr; use std::net::SocketAddr;
use std::sync::Arc; use std::sync::Arc;
@ -195,7 +194,7 @@ impl AuthenticatedClient {
block_selector: BlockSelector, block_selector: BlockSelector,
_addition_records: &[AdditionRecord], _addition_records: &[AdditionRecord],
) -> ::core::result::Result< ) -> ::core::result::Result<
RpcResult<Option<HashMap<AdditionRecord, Option<u64>>>>, RpcResult<Vec<(AdditionRecord, Option<u64>)>>,
::tarpc::client::RpcError, ::tarpc::client::RpcError,
> { > {
let rpc_result = self let rpc_result = self
@ -204,7 +203,7 @@ impl AuthenticatedClient {
.await; .await;
// if the RPC call was successful, return that // if the RPC call was successful, return that
if let Ok(Ok(Some(_))) = rpc_result { if let Ok(Ok(_)) = rpc_result {
return rpc_result; return rpc_result;
} }