Correct invalid RPC type def in monero-rpc

This commit is contained in:
Luke Parker
2024-06-28 16:01:34 -04:00
parent 08d604fcb3
commit 891362a710
2 changed files with 6 additions and 6 deletions

View File

@@ -261,7 +261,7 @@ pub trait Rpc: Sync + Clone + Debug {
let res_str = std_shims::str::from_utf8(&res) let res_str = std_shims::str::from_utf8(&res)
.map_err(|_| RpcError::InvalidNode("response wasn't utf-8".to_string()))?; .map_err(|_| RpcError::InvalidNode("response wasn't utf-8".to_string()))?;
serde_json::from_str(res_str) serde_json::from_str(res_str)
.map_err(|_| RpcError::InvalidNode(format!("response wasn't json: {res_str}"))) .map_err(|_| RpcError::InvalidNode(format!("response wasn't the expected json: {res_str}")))
} }
/// Perform a JSON-RPC call with the specified method with the provided parameters. /// Perform a JSON-RPC call with the specified method with the provided parameters.
@@ -285,15 +285,15 @@ pub trait Rpc: Sync + Clone + Debug {
/// Get the active blockchain protocol version. /// Get the active blockchain protocol version.
/// ///
/// This is specifically the major version within the most recent block header. /// This is specifically the major version within the most recent block header.
async fn get_protocol(&self) -> Result<u8, RpcError> { async fn get_hardfork_version(&self) -> Result<u8, RpcError> {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct ProtocolResponse { struct HeaderResponse {
hardfork_version: u8, major_version: u8,
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct LastHeaderResponse { struct LastHeaderResponse {
block_header: ProtocolResponse, block_header: HeaderResponse,
} }
Ok( Ok(
@@ -301,7 +301,7 @@ pub trait Rpc: Sync + Clone + Debug {
.json_rpc_call::<LastHeaderResponse>("get_last_block_header", None) .json_rpc_call::<LastHeaderResponse>("get_last_block_header", None)
.await? .await?
.block_header .block_header
.hardfork_version, .major_version,
) )
} }