1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-24 15:02:21 +01:00

Log daemon's network info

(including its version string)
This commit is contained in:
Roman Zeyde 2018-07-14 17:13:34 +03:00
parent 253e244a86
commit 00de0c028c
No known key found for this signature in database
GPG key ID: 87CAE5FA46917CBB

View file

@ -75,6 +75,12 @@ pub struct BlockchainInfo {
pruned: bool,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct NetworkInfo {
version: u64,
subversion: String,
}
pub struct MempoolEntry {
fee: u64, // in satoshis
vsize: u32, // in virtual bytes (= weight/4)
@ -210,6 +216,7 @@ impl Daemon {
),
};
debug!("{:?}", daemon.getblockchaininfo()?);
debug!("{:?}", daemon.getnetworkinfo()?);
Ok(daemon)
}
@ -287,6 +294,11 @@ impl Daemon {
Ok(from_value(info).chain_err(|| "invalid blockchain info")?)
}
pub fn getnetworkinfo(&self) -> Result<NetworkInfo> {
let info: Value = self.request("getnetworkinfo", json!([]))?;
Ok(from_value(info).chain_err(|| "invalid network info")?)
}
pub fn getbestblockhash(&self) -> Result<Sha256dHash> {
parse_hash(&self.request("getbestblockhash", json!([]))?).chain_err(|| "invalid blockhash")
}