Skip to content

Commit 8a26cd0

Browse files
committed
Improve GetPeerInfo
In #310 I got mixed up and added fields to the v17 types `GetPeerInfo` struct that do not appear in the docs. This was masked by using `Option`. And not helped by the fact that a bunch of other `Option`s are used because the docs do not match what Core returns. These bugs propagated up through the version numbers. Go over them all and sort it out. Note also that we were incorrectly re-exporting `PeerInfo` from v19 even though the `PeerInfo` struct that was actually being used is found in the version specific file along with `GetPeerInfo` - face palm. And finally, remove all the 'vXY and later' docs, this is implied by the module. These sorts of comments should only be found in `model`.
1 parent 35ef25c commit 8a26cd0

File tree

13 files changed

+57
-84
lines changed

13 files changed

+57
-84
lines changed

types/src/v17/network/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ pub struct PeerInfo {
196196
/// Local address as reported by the peer.
197197
#[serde(rename = "addrlocal")]
198198
pub address_local: Option<String>,
199-
/// Network (ipv4, ipv6, or onion) the peer connected through.
200-
pub network: Option<String>,
201199
/// The services offered.
202200
pub services: String,
203201
/// Whether peer has asked us to relay transactions to it.
@@ -252,16 +250,14 @@ pub struct PeerInfo {
252250
pub synced_blocks: i64,
253251
/// The heights of blocks we're currently asking from this peer.
254252
pub inflight: Vec<u64>,
255-
/// Whether the peer is whitelisted (deprecated in v0.21).
253+
/// Whether the peer is whitelisted.
256254
pub whitelisted: Option<bool>,
257255
/// The total bytes sent aggregated by message type.
258256
#[serde(rename = "bytessent_per_msg")]
259257
pub bytes_sent_per_message: BTreeMap<String, u64>,
260258
/// The total bytes received aggregated by message type.
261259
#[serde(rename = "bytesrecv_per_msg")]
262260
pub bytes_received_per_message: BTreeMap<String, u64>,
263-
/// Type of connection.
264-
pub connection_type: Option<String>,
265261
}
266262

267263
/// Result of JSON-RPC method `listbanned`.

types/src/v18/network/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ pub struct PeerInfo {
5757
/// Local address as reported by the peer.
5858
#[serde(rename = "addrlocal")]
5959
pub address_local: Option<String>,
60-
/// Network (ipv4, ipv6, or onion) the peer connected through.
61-
pub network: Option<String>,
6260
/// The services offered.
6361
pub services: String,
6462
/// Whether peer has asked us to relay transactions to it.
@@ -113,17 +111,15 @@ pub struct PeerInfo {
113111
pub synced_blocks: i64,
114112
/// The heights of blocks we're currently asking from this peer.
115113
pub inflight: Vec<u64>,
116-
/// Whether the peer is whitelisted (deprecated in v0.21).
114+
/// Whether the peer is whitelisted.
117115
pub whitelisted: Option<bool>,
118116
/// The minimum fee rate for transactions this peer accepts.
119117
#[serde(rename = "minfeefilter")]
120-
pub min_fee_filter: Option<f64>,
118+
pub min_fee_filter: f64,
121119
/// The total bytes sent aggregated by message type.
122120
#[serde(rename = "bytessent_per_msg")]
123121
pub bytes_sent_per_message: BTreeMap<String, u64>,
124122
/// The total bytes received aggregated by message type.
125123
#[serde(rename = "bytesrecv_per_msg")]
126124
pub bytes_received_per_message: BTreeMap<String, u64>,
127-
/// Type of connection.
128-
pub connection_type: Option<String>,
129125
}

types/src/v19/network/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct GetNetworkInfo {
3030
/// The services we offer to the network (hex string).
3131
#[serde(rename = "localservices")]
3232
pub local_services: String,
33-
/// The services we offer to the network. v0.19 and later only.
33+
/// The services we offer to the network.
3434
#[serde(rename = "localservicesnames")]
3535
pub local_services_names: Vec<String>,
3636
/// `true` if transaction relay is requested from peers.
@@ -83,11 +83,9 @@ pub struct PeerInfo {
8383
/// Local address as reported by the peer.
8484
#[serde(rename = "addrlocal")]
8585
pub address_local: Option<String>,
86-
/// Network (ipv4, ipv6, or onion) the peer connected through.
87-
pub network: Option<String>,
8886
/// The services offered.
8987
pub services: String,
90-
/// The services offered, in human-readable form. v0.19 and later only.
88+
/// The services offered, in human-readable form.
9189
#[serde(rename = "servicesnames")]
9290
pub services_names: Vec<String>,
9391
/// Whether peer has asked us to relay transactions to it.
@@ -144,17 +142,15 @@ pub struct PeerInfo {
144142
pub inflight: Vec<u64>,
145143
/// Any special permissions that have been granted to this peer. v0.19 and later only.
146144
pub permissions: Vec<String>,
147-
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
148-
#[serde(rename = "minfeefilter")]
149-
pub minimum_fee_filter: f64,
150-
/// Whether the peer is whitelisted (deprecated in v0.21).
145+
/// Whether the peer is whitelisted.
151146
pub whitelisted: Option<bool>,
147+
/// The minimum fee rate for transactions this peer accepts.
148+
#[serde(rename = "minfeefilter")]
149+
pub min_fee_filter: f64,
152150
/// The total bytes sent aggregated by message type.
153151
#[serde(rename = "bytessent_per_msg")]
154152
pub bytes_sent_per_message: BTreeMap<String, u64>,
155153
/// The total bytes received aggregated by message type.
156154
#[serde(rename = "bytesrecv_per_msg")]
157155
pub bytes_received_per_message: BTreeMap<String, u64>,
158-
/// Type of connection.
159-
pub connection_type: Option<String>,
160156
}

types/src/v21/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub use self::{
245245
SoftforkType,
246246
},
247247
generating::GenerateBlock,
248-
network::{GetNetworkInfo, GetPeerInfo},
248+
network::{GetNetworkInfo, GetPeerInfo, PeerInfo},
249249
util::{GetIndexInfo, GetIndexInfoName},
250250
wallet::{
251251
ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError,
@@ -298,8 +298,7 @@ pub use crate::{
298298
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError,
299299
GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors, GetMempoolAncestorsVerbose,
300300
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError,
301-
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
302-
SetWalletFlag,
301+
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag,
303302
},
304303
v20::{
305304
Banned, CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail,

types/src/v21/network/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct PeerInfo {
9191
pub network: Option<String>,
9292
/// The services offered.
9393
pub services: String,
94-
/// The services offered, in human-readable form. v0.19 and later only.
94+
/// The services offered, in human-readable form.
9595
#[serde(rename = "servicesnames")]
9696
pub services_names: Vec<String>,
9797
/// Whether peer has asked us to relay transactions to it.
@@ -141,9 +141,6 @@ pub struct PeerInfo {
141141
/// The starting height (block) of the peer.
142142
#[serde(rename = "startingheight")]
143143
pub starting_height: i64,
144-
/// The ban score.
145-
#[serde(rename = "banscore")]
146-
pub ban_score: Option<i64>,
147144
/// The last header we have in common with this peer.
148145
pub synced_headers: i64,
149146
/// The last block we have in common with this peer.
@@ -159,11 +156,11 @@ pub struct PeerInfo {
159156
pub addresses_rate_limited: usize,
160157
/// Any special permissions that have been granted to this peer. v0.19 and later only.
161158
pub permissions: Vec<String>,
162-
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
163-
#[serde(rename = "minfeefilter")]
164-
pub minimum_fee_filter: f64,
165-
/// Whether the peer is whitelisted (deprecated in v0.21).
159+
/// Whether the peer is whitelisted.
166160
pub whitelisted: Option<bool>,
161+
/// The minimum fee rate for transactions this peer accepts.
162+
#[serde(rename = "minfeefilter")]
163+
pub min_fee_filter: Option<f64>, // Docs rekon this exists.
167164
/// The total bytes sent aggregated by message type.
168165
#[serde(rename = "bytessent_per_msg")]
169166
pub bytes_sent_per_message: BTreeMap<String, u64>,

types/src/v22/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ mod wallet;
254254
pub use self::{
255255
blockchain::GetMempoolInfo,
256256
control::Logging,
257-
network::{Banned, GetPeerInfo, ListBanned},
257+
network::{Banned, GetPeerInfo, ListBanned, PeerInfo},
258258
raw_transactions::{DecodeScript, DecodeScriptError},
259259
signer::EnumerateSigners,
260260
wallet::{ListDescriptors, WalletDisplayAddress},
@@ -305,8 +305,7 @@ pub use crate::{
305305
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError,
306306
GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors, GetMempoolAncestorsVerbose,
307307
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError,
308-
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
309-
SetWalletFlag,
308+
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag,
310309
},
311310
v20::{CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail},
312311
v21::{

types/src/v22/network.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub struct PeerInfo {
6161
pub network: Option<String>,
6262
/// The services offered.
6363
pub services: String,
64-
/// The services offered, in human-readable form. v0.19 and later only.
64+
/// The services offered, in human-readable form.
6565
#[serde(rename = "servicesnames")]
6666
pub services_names: Vec<String>,
6767
/// Whether peer has asked us to relay transactions to it.
@@ -105,19 +105,16 @@ pub struct PeerInfo {
105105
pub subversion: String,
106106
/// Inbound (true) or Outbound (false).
107107
pub inbound: bool,
108-
/// Whether we selected peer as (compact blocks) high-bandwidth peer. v22 and later only.
108+
/// Whether we selected peer as (compact blocks) high-bandwidth peer.
109109
pub bip152_hb_to: bool,
110-
/// Whether peer selected us as (compact blocks) high-bandwidth peer. v22 and later only.
110+
/// Whether peer selected us as (compact blocks) high-bandwidth peer.
111111
pub bip152_hb_from: bool,
112112
/// Whether connection was due to addnode/-connect or if it was an automatic/inbound connection.
113113
#[serde(rename = "addnode")]
114114
pub add_node: Option<bool>,
115115
/// The starting height (block) of the peer.
116116
#[serde(rename = "startingheight")]
117117
pub starting_height: i64,
118-
/// The ban score.
119-
#[serde(rename = "banscore")]
120-
pub ban_score: Option<i64>,
121118
/// The last header we have in common with this peer.
122119
pub synced_headers: i64,
123120
/// The last block we have in common with this peer.
@@ -133,11 +130,11 @@ pub struct PeerInfo {
133130
pub addresses_rate_limited: usize,
134131
/// Any special permissions that have been granted to this peer. v0.19 and later only.
135132
pub permissions: Vec<String>,
136-
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
137-
#[serde(rename = "minfeefilter")]
138-
pub minimum_fee_filter: f64,
139-
/// Whether the peer is whitelisted (deprecated in v0.21).
133+
/// Whether the peer is whitelisted.
140134
pub whitelisted: Option<bool>,
135+
/// The minimum fee rate for transactions this peer accepts.
136+
#[serde(rename = "minfeefilter")]
137+
pub min_fee_filter: Option<f64>, // Docs rekon this exists.
141138
/// The total bytes sent aggregated by message type.
142139
#[serde(rename = "bytessent_per_msg")]
143140
pub bytes_sent_per_message: BTreeMap<String, u64>,

types/src/v23/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub use self::{
250250
GetDeploymentInfoError, GetMempoolEntry, SaveMempool,
251251
},
252252
control::Logging,
253-
network::GetPeerInfo,
253+
network::{GetPeerInfo, PeerInfo},
254254
raw_transactions::{
255255
DecodePsbt, DecodePsbtError, DecodeScript, DecodeScriptError, GlobalXpub, Proprietary,
256256
PsbtInput, PsbtOutput,
@@ -304,8 +304,8 @@ pub use crate::{
304304
GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo,
305305
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
306306
GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError, MempoolEntry,
307-
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag,
308-
Softfork, SoftforkType,
307+
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag, Softfork,
308+
SoftforkType,
309309
},
310310
v20::{GenerateToDescriptor, GetTransactionDetail},
311311
v21::{

types/src/v23/network.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,20 @@ pub struct PeerInfo {
9999
pub synced_blocks: Option<i64>,
100100
/// The heights of blocks we're currently asking from this peer.
101101
pub inflight: Option<Vec<u64>>,
102-
/// Whether we participate in address relay with this peer. v23 and later only.
102+
/// Whether we participate in address relay with this peer.
103103
#[serde(rename = "addr_relay_enabled")]
104104
pub addresses_relay_enabled: Option<bool>,
105-
/// The total number of addresses processed, excluding those dropped due to rate limiting. v21 and
106-
/// later only.
105+
/// The total number of addresses processed, excluding those dropped due to rate limiting.
107106
#[serde(rename = "addr_processed")]
108107
pub addresses_processed: Option<usize>,
109-
/// The total number of addresses dropped due to rate limiting. v21 and later only.
108+
/// The total number of addresses dropped due to rate limiting.
110109
#[serde(rename = "addr_rate_limited")]
111110
pub addresses_rate_limited: Option<usize>,
112-
/// Any special permissions that have been granted to this peer. v0.19 and later only.
111+
/// Any special permissions that have been granted to this peer.
113112
pub permissions: Vec<String>,
114-
/// The minimum fee rate for transactions this peer accepts. v0.19 and later only.
113+
/// The minimum fee rate for transactions this peer accepts.
115114
#[serde(rename = "minfeefilter")]
116115
pub minimum_fee_filter: f64,
117-
/// Whether the peer is whitelisted (deprecated in v0.21).
118-
pub whitelisted: Option<bool>,
119116
/// The total bytes sent aggregated by message type.
120117
#[serde(rename = "bytessent_per_msg")]
121118
pub bytes_sent_per_message: BTreeMap<String, u64>,

types/src/v24/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub use self::{
251251
GetMempoolEntry, GetMempoolInfo, GetTxSpendingPrevout, GetTxSpendingPrevoutError,
252252
GetTxSpendingPrevoutItem,
253253
},
254-
network::GetPeerInfo,
254+
network::{GetPeerInfo, PeerInfo},
255255
raw_transactions::{
256256
DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, PsbtOutput,
257257
TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig,
@@ -306,8 +306,8 @@ pub use crate::{
306306
GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo,
307307
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
308308
GetMempoolDescendantsVerbose, GetRpcInfo, MapMempoolEntryError, MempoolEntry,
309-
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag,
310-
Softfork, SoftforkType,
309+
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag, Softfork,
310+
SoftforkType,
311311
},
312312
v20::GenerateToDescriptor,
313313
v21::{

0 commit comments

Comments
 (0)