diff --git a/zebra-rpc/Cargo.toml b/zebra-rpc/Cargo.toml index 119e9ece801..283c4c514c2 100644 --- a/zebra-rpc/Cargo.toml +++ b/zebra-rpc/Cargo.toml @@ -43,7 +43,7 @@ jsonrpc-http-server = "18.0.0" num_cpus = "1.14.0" # zebra-rpc needs the preserve_order feature in serde_json, which is a dependency of jsonrpc-core -serde_json = { version = "1.0.89", features = ["preserve_order", "arbitrary_precision"] } +serde_json = { version = "1.0.89", features = ["preserve_order"] } indexmap = { version = "1.9.2", features = ["serde"] } tokio = { version = "1.23.0", features = ["time", "rt-multi-thread", "macros", "tracing"] } diff --git a/zebra-rpc/src/methods/get_block_template_rpcs.rs b/zebra-rpc/src/methods/get_block_template_rpcs.rs index bfe98f5535d..e15677e1b5f 100644 --- a/zebra-rpc/src/methods/get_block_template_rpcs.rs +++ b/zebra-rpc/src/methods/get_block_template_rpcs.rs @@ -142,7 +142,7 @@ pub trait GetBlockTemplateRpc { &self, num_blocks: Option, height: Option, - ) -> BoxFuture>; + ) -> BoxFuture>; /// Returns the estimated network solutions per second based on the last `num_blocks` before `height`. /// If `num_blocks` is not supplied, uses 120 blocks. @@ -154,7 +154,7 @@ pub trait GetBlockTemplateRpc { &self, num_blocks: Option, height: Option, - ) -> BoxFuture> { + ) -> BoxFuture> { self.get_network_sol_ps(num_blocks, height) } } @@ -577,7 +577,7 @@ where &self, num_blocks: Option, height: Option, - ) -> BoxFuture> { + ) -> BoxFuture> { let num_blocks = num_blocks .map(|num_blocks| num_blocks.max(1)) .unwrap_or(DEFAULT_SOLUTION_RATE_WINDOW_SIZE); @@ -606,7 +606,9 @@ where _ => unreachable!("unmatched response to a solution rate request"), }; - Ok(solution_rate) + Ok(solution_rate + .try_into() + .expect("per-second solution rate always fits in u64")) } .boxed() } diff --git a/zebra-rpc/src/methods/get_block_template_rpcs/types/get_mining_info.rs b/zebra-rpc/src/methods/get_block_template_rpcs/types/get_mining_info.rs index a75984489b0..3ac548596cb 100644 --- a/zebra-rpc/src/methods/get_block_template_rpcs/types/get_mining_info.rs +++ b/zebra-rpc/src/methods/get_block_template_rpcs/types/get_mining_info.rs @@ -6,10 +6,10 @@ use zebra_chain::parameters::Network; #[derive(Debug, PartialEq, Eq, serde::Serialize)] pub struct Response { /// The estimated network solution rate in Sol/s. - networksolps: u128, + networksolps: u64, /// The estimated network solution rate in Sol/s. - networkhashps: u128, + networkhashps: u64, /// Current network name as defined in BIP70 (main, test, regtest) chain: String, @@ -20,7 +20,7 @@ pub struct Response { impl Response { /// Creates a new `getmininginfo` response - pub fn new(network: Network, networksolps: u128) -> Self { + pub fn new(network: Network, networksolps: u64) -> Self { Self { networksolps, networkhashps: networksolps, diff --git a/zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs b/zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs index 9162a998363..4c0f3379174 100644 --- a/zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs +++ b/zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs @@ -250,6 +250,6 @@ fn snapshot_rpc_getmininginfo( } /// Snapshot `getnetworksolps` response, using `cargo insta` and JSON serialization. -fn snapshot_rpc_getnetworksolps(get_network_sol_ps: u128, settings: &insta::Settings) { +fn snapshot_rpc_getnetworksolps(get_network_sol_ps: u64, settings: &insta::Settings) { settings.bind(|| insta::assert_json_snapshot!("get_network_sol_ps", get_network_sol_ps)); }