Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions integration_test/tests/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ fn get_peer_info_three_node_network() {
node2.mine_a_block();
node3.mine_a_block();

let json: GetPeerInfo = node1.client.get_peer_info().expect("getpeerinfo");
// This verifies that we re-exported the correct `PeerInfo` type at the module level.
let _: PeerInfo = json.0[0];

// FIXME: Fails if we use equal to 2 ???
assert!(node1.peers_connected() >= 1);
assert!(node2.peers_connected() >= 1);
Expand Down
6 changes: 2 additions & 4 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,8 @@ mod test {
}

fn peers_connected(client: &Client) -> usize {
// FIXME: Once client implements get_peer_info use it.
// This is kinda cool, it shows we can call any RPC method using the client.
let result: Vec<serde_json::Value> = client.call("getpeerinfo", &[]).unwrap();
result.len()
let json = client.get_peer_info().expect("get_peer_info");
json.0.len()
}

fn init() -> String {
Expand Down
6 changes: 1 addition & 5 deletions types/src/v17/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ pub struct PeerInfo {
/// Local address as reported by the peer.
#[serde(rename = "addrlocal")]
pub address_local: Option<String>,
/// Network (ipv4, ipv6, or onion) the peer connected through.
pub network: Option<String>,
/// The services offered.
pub services: String,
/// Whether peer has asked us to relay transactions to it.
Expand Down Expand Up @@ -252,16 +250,14 @@ pub struct PeerInfo {
pub synced_blocks: i64,
/// The heights of blocks we're currently asking from this peer.
pub inflight: Vec<u64>,
/// Whether the peer is whitelisted (deprecated in v0.21).
/// Whether the peer is whitelisted.
pub whitelisted: Option<bool>,
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
/// The total bytes received aggregated by message type.
#[serde(rename = "bytesrecv_per_msg")]
pub bytes_received_per_message: BTreeMap<String, u64>,
/// Type of connection.
pub connection_type: Option<String>,
}

/// Result of JSON-RPC method `listbanned`.
Expand Down
8 changes: 2 additions & 6 deletions types/src/v18/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ pub struct PeerInfo {
/// Local address as reported by the peer.
#[serde(rename = "addrlocal")]
pub address_local: Option<String>,
/// Network (ipv4, ipv6, or onion) the peer connected through.
pub network: Option<String>,
/// The services offered.
pub services: String,
/// Whether peer has asked us to relay transactions to it.
Expand Down Expand Up @@ -113,17 +111,15 @@ pub struct PeerInfo {
pub synced_blocks: i64,
/// The heights of blocks we're currently asking from this peer.
pub inflight: Vec<u64>,
/// Whether the peer is whitelisted (deprecated in v0.21).
/// Whether the peer is whitelisted.
pub whitelisted: Option<bool>,
/// The minimum fee rate for transactions this peer accepts.
#[serde(rename = "minfeefilter")]
pub min_fee_filter: Option<f64>,
pub min_fee_filter: f64,
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
/// The total bytes received aggregated by message type.
#[serde(rename = "bytesrecv_per_msg")]
pub bytes_received_per_message: BTreeMap<String, u64>,
/// Type of connection.
pub connection_type: Option<String>,
}
16 changes: 6 additions & 10 deletions types/src/v19/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct GetNetworkInfo {
/// The services we offer to the network (hex string).
#[serde(rename = "localservices")]
pub local_services: String,
/// The services we offer to the network. v0.19 and later only.
/// The services we offer to the network.
#[serde(rename = "localservicesnames")]
pub local_services_names: Vec<String>,
/// `true` if transaction relay is requested from peers.
Expand Down Expand Up @@ -83,11 +83,9 @@ pub struct PeerInfo {
/// Local address as reported by the peer.
#[serde(rename = "addrlocal")]
pub address_local: Option<String>,
/// Network (ipv4, ipv6, or onion) the peer connected through.
pub network: Option<String>,
/// The services offered.
pub services: String,
/// The services offered, in human-readable form. v0.19 and later only.
/// The services offered, in human-readable form.
#[serde(rename = "servicesnames")]
pub services_names: Vec<String>,
/// Whether peer has asked us to relay transactions to it.
Expand Down Expand Up @@ -144,17 +142,15 @@ pub struct PeerInfo {
pub inflight: Vec<u64>,
/// Any special permissions that have been granted to this peer. v0.19 and later only.
pub permissions: Vec<String>,
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
#[serde(rename = "minfeefilter")]
pub minimum_fee_filter: f64,
/// Whether the peer is whitelisted (deprecated in v0.21).
/// Whether the peer is whitelisted.
pub whitelisted: Option<bool>,
/// The minimum fee rate for transactions this peer accepts.
#[serde(rename = "minfeefilter")]
pub min_fee_filter: f64,
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
/// The total bytes received aggregated by message type.
#[serde(rename = "bytesrecv_per_msg")]
pub bytes_received_per_message: BTreeMap<String, u64>,
/// Type of connection.
pub connection_type: Option<String>,
}
5 changes: 2 additions & 3 deletions types/src/v21/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub use self::{
SoftforkType,
},
generating::GenerateBlock,
network::{GetNetworkInfo, GetPeerInfo},
network::{GetNetworkInfo, GetPeerInfo, PeerInfo},
util::{GetIndexInfo, GetIndexInfoName},
wallet::{
ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError,
Expand Down Expand Up @@ -298,8 +298,7 @@ pub use crate::{
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError,
GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors, GetMempoolAncestorsVerbose,
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError,
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
SetWalletFlag,
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types/src/v21/mod.rs:248 Missing PeerInfo export in network.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks. Fixed.

},
v20::{
Banned, CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail,
Expand Down
13 changes: 5 additions & 8 deletions types/src/v21/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct PeerInfo {
pub network: Option<String>,
/// The services offered.
pub services: String,
/// The services offered, in human-readable form. v0.19 and later only.
/// The services offered, in human-readable form.
#[serde(rename = "servicesnames")]
pub services_names: Vec<String>,
/// Whether peer has asked us to relay transactions to it.
Expand Down Expand Up @@ -141,9 +141,6 @@ pub struct PeerInfo {
/// The starting height (block) of the peer.
#[serde(rename = "startingheight")]
pub starting_height: i64,
/// The ban score.
#[serde(rename = "banscore")]
pub ban_score: Option<i64>,
/// The last header we have in common with this peer.
pub synced_headers: i64,
/// The last block we have in common with this peer.
Expand All @@ -159,11 +156,11 @@ pub struct PeerInfo {
pub addresses_rate_limited: usize,
/// Any special permissions that have been granted to this peer. v0.19 and later only.
pub permissions: Vec<String>,
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
#[serde(rename = "minfeefilter")]
pub minimum_fee_filter: f64,
/// Whether the peer is whitelisted (deprecated in v0.21).
/// Whether the peer is whitelisted.
pub whitelisted: Option<bool>,
/// The minimum fee rate for transactions this peer accepts.
#[serde(rename = "minfeefilter")]
pub min_fee_filter: Option<f64>, // Docs rekon this exists.
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
Expand Down
5 changes: 2 additions & 3 deletions types/src/v22/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ mod wallet;
pub use self::{
blockchain::GetMempoolInfo,
control::Logging,
network::{Banned, GetPeerInfo, ListBanned},
network::{Banned, GetPeerInfo, ListBanned, PeerInfo},
raw_transactions::{DecodeScript, DecodeScriptError},
signer::EnumerateSigners,
wallet::{ListDescriptors, WalletDisplayAddress},
Expand Down Expand Up @@ -305,8 +305,7 @@ pub use crate::{
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError,
GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors, GetMempoolAncestorsVerbose,
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError,
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
SetWalletFlag,
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag,
},
v20::{CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail},
v21::{
Expand Down
17 changes: 7 additions & 10 deletions types/src/v22/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct PeerInfo {
pub network: Option<String>,
/// The services offered.
pub services: String,
/// The services offered, in human-readable form. v0.19 and later only.
/// The services offered, in human-readable form.
#[serde(rename = "servicesnames")]
pub services_names: Vec<String>,
/// Whether peer has asked us to relay transactions to it.
Expand Down Expand Up @@ -105,19 +105,16 @@ pub struct PeerInfo {
pub subversion: String,
/// Inbound (true) or Outbound (false).
pub inbound: bool,
/// Whether we selected peer as (compact blocks) high-bandwidth peer. v22 and later only.
/// Whether we selected peer as (compact blocks) high-bandwidth peer.
pub bip152_hb_to: bool,
/// Whether peer selected us as (compact blocks) high-bandwidth peer. v22 and later only.
/// Whether peer selected us as (compact blocks) high-bandwidth peer.
pub bip152_hb_from: bool,
/// Whether connection was due to addnode/-connect or if it was an automatic/inbound connection.
#[serde(rename = "addnode")]
pub add_node: Option<bool>,
/// The starting height (block) of the peer.
#[serde(rename = "startingheight")]
pub starting_height: i64,
/// The ban score.
#[serde(rename = "banscore")]
pub ban_score: Option<i64>,
/// The last header we have in common with this peer.
pub synced_headers: i64,
/// The last block we have in common with this peer.
Expand All @@ -133,11 +130,11 @@ pub struct PeerInfo {
pub addresses_rate_limited: usize,
/// Any special permissions that have been granted to this peer. v0.19 and later only.
pub permissions: Vec<String>,
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
#[serde(rename = "minfeefilter")]
pub minimum_fee_filter: f64,
/// Whether the peer is whitelisted (deprecated in v0.21).
/// Whether the peer is whitelisted.
pub whitelisted: Option<bool>,
/// The minimum fee rate for transactions this peer accepts.
#[serde(rename = "minfeefilter")]
pub min_fee_filter: Option<f64>, // Docs rekon this exists.
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
Expand Down
6 changes: 3 additions & 3 deletions types/src/v23/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub use self::{
GetDeploymentInfoError, GetMempoolEntry, SaveMempool,
},
control::Logging,
network::GetPeerInfo,
network::{GetPeerInfo, PeerInfo},
raw_transactions::{
DecodePsbt, DecodePsbtError, DecodeScript, DecodeScriptError, GlobalXpub, Proprietary,
PsbtInput, PsbtOutput,
Expand Down Expand Up @@ -304,8 +304,8 @@ pub use crate::{
GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo,
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError, MempoolEntry,
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag,
Softfork, SoftforkType,
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag, Softfork,
SoftforkType,
},
v20::{GenerateToDescriptor, GetTransactionDetail},
v21::{
Expand Down
13 changes: 5 additions & 8 deletions types/src/v23/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,20 @@ pub struct PeerInfo {
pub synced_blocks: Option<i64>,
/// The heights of blocks we're currently asking from this peer.
pub inflight: Option<Vec<u64>>,
/// Whether we participate in address relay with this peer. v23 and later only.
/// Whether we participate in address relay with this peer.
#[serde(rename = "addr_relay_enabled")]
pub addresses_relay_enabled: Option<bool>,
/// The total number of addresses processed, excluding those dropped due to rate limiting. v21 and
/// later only.
/// The total number of addresses processed, excluding those dropped due to rate limiting.
#[serde(rename = "addr_processed")]
pub addresses_processed: Option<usize>,
/// The total number of addresses dropped due to rate limiting. v21 and later only.
/// The total number of addresses dropped due to rate limiting.
#[serde(rename = "addr_rate_limited")]
pub addresses_rate_limited: Option<usize>,
/// Any special permissions that have been granted to this peer. v0.19 and later only.
/// Any special permissions that have been granted to this peer.
pub permissions: Vec<String>,
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
/// The minimum fee rate for transactions this peer accepts.
#[serde(rename = "minfeefilter")]
pub minimum_fee_filter: f64,
/// Whether the peer is whitelisted (deprecated in v0.21).
pub whitelisted: Option<bool>,
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
Expand Down
6 changes: 3 additions & 3 deletions types/src/v24/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub use self::{
GetMempoolEntry, GetMempoolInfo, GetTxSpendingPrevout, GetTxSpendingPrevoutError,
GetTxSpendingPrevoutItem,
},
network::GetPeerInfo,
network::{GetPeerInfo, PeerInfo},
raw_transactions::{
DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, PsbtOutput,
TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig,
Expand Down Expand Up @@ -306,8 +306,8 @@ pub use crate::{
GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo,
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError, MempoolEntry,
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag,
Softfork, SoftforkType,
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag, Softfork,
SoftforkType,
},
v20::GenerateToDescriptor,
v21::{
Expand Down
15 changes: 6 additions & 9 deletions types/src/v24/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct PeerInfo {
#[serde(rename = "startingheight")]
pub starting_height: Option<i64>,
/// The current height of header pre-synchronization with this peer, or -1 if no low-work sync is
/// in progress. v24 and later only.
/// in progress.
pub presynced_headers: Option<i64>,
/// The ban score.
#[serde(rename = "banscore")]
Expand All @@ -102,23 +102,20 @@ pub struct PeerInfo {
pub synced_blocks: Option<i64>,
/// The heights of blocks we're currently asking from this peer.
pub inflight: Option<Vec<u64>>,
/// Whether we participate in address relay with this peer. v23 and later only.
/// Whether we participate in address relay with this peer.
#[serde(rename = "addr_relay_enabled")]
pub addresses_relay_enabled: Option<bool>,
/// The total number of addresses processed, excluding those dropped due to rate limiting. v21 and
/// later only.
/// The total number of addresses processed, excluding those dropped due to rate limiting.
#[serde(rename = "addr_processed")]
pub addresses_processed: Option<usize>,
/// The total number of addresses dropped due to rate limiting. v21 and later only.
/// The total number of addresses dropped due to rate limiting.
#[serde(rename = "addr_rate_limited")]
pub addresses_rate_limited: Option<usize>,
/// Any special permissions that have been granted to this peer. v0.19 and later only.
/// Any special permissions that have been granted to this peer.
pub permissions: Vec<String>,
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
/// The minimum fee rate for transactions this peer accepts.
#[serde(rename = "minfeefilter")]
pub minimum_fee_filter: f64,
/// Whether the peer is whitelisted (deprecated in v0.21).
pub whitelisted: Option<bool>,
/// The total bytes sent aggregated by message type.
#[serde(rename = "bytessent_per_msg")]
pub bytes_sent_per_message: BTreeMap<String, u64>,
Expand Down
6 changes: 3 additions & 3 deletions types/src/v25/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ pub use crate::{
GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo,
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError, MempoolEntry,
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag,
Softfork, SoftforkType,
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag, Softfork,
SoftforkType,
},
v20::GenerateToDescriptor,
v21::{
Expand All @@ -315,7 +315,7 @@ pub use crate::{
v24::{
DecodePsbt, DecodePsbtError, GetMempoolEntry, GetMempoolInfo, GetPeerInfo, GetTransaction,
GetTransactionDetail, GetTransactionError, GetTxSpendingPrevout, GetTxSpendingPrevoutError,
GlobalXpub, ListUnspent, ListUnspentItem, MigrateWallet, Proprietary, PsbtInput,
GlobalXpub, ListUnspent, ListUnspentItem, MigrateWallet, PeerInfo, Proprietary, PsbtInput,
PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf,
TaprootScript, TaprootScriptPathSig,
},
Expand Down
Loading