Skip to content

Commit

Permalink
add: support for getrawaddrman
Browse files Browse the repository at this point in the history
  • Loading branch information
0xB10C committed May 8, 2024
1 parent f19c1b5 commit ab4ae77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,11 @@ pub trait RpcApi: Sized {
self.call("getnettotals", &[])
}

/// Returns the addresses in the nodes address manager tables.
fn get_raw_addrman(&self) -> Result<json::GetRawAddrmanResult> {
self.call("getrawaddrman", &[])
}

/// Returns the estimated network hashes per second based on the last n blocks.
fn get_network_hash_ps(&self, nblocks: Option<u64>, height: Option<u64>) -> Result<f64> {
let mut args = [opt_into_json(nblocks)?, opt_into_json(height)?];
Expand Down
19 changes: 19 additions & 0 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,25 @@ impl<'a> serde::Serialize for PubKeyOrAddress<'a> {
}
}

type GetRawAddrmanResultKey = String;

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct GetRawAddrmanResult {
pub new: HashMap<GetRawAddrmanResultKey, GetRawAddrmanResultAddress>,
pub tried: HashMap<GetRawAddrmanResultKey, GetRawAddrmanResultAddress>,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
pub struct GetRawAddrmanResultAddress {
pub address: String,
pub port: u16,
pub services: u64,
pub time: u32,
pub network: String,
pub source: String,
pub source_network: String,
}

// Custom deserializer functions.

/// deserialize_hex_array_opt deserializes a vector of hex-encoded byte arrays.
Expand Down

0 comments on commit ab4ae77

Please sign in to comment.