Skip to content

Commit 5af7bb0

Browse files
committed
Merge #318: Address all TODO in v27
93ed34f Run the formatter (Jamil Lambert, PhD) 0132f7a Redefine getnodeaddresses in v27 (Jamil Lambert, PhD) Pull request description: Go through all the TODO in the v26 types table. - Redefine `getnodeaddresses`: There were return field changes in v27. Redefine the struct and update the reexports. Update the types tables. - Run the formatter: Done separately to make it easier to see the changes in patch 1. DRAFT because on top of #321. This PR is the last 2 patches. ACKs for top commit: jrakibi: ACK 93ed34f tcharding: ACK 93ed34f Tree-SHA512: 8cd4ca5ae831bb0ff65a00194149b31cf543fbbc23acd29801462bb16b7200a020df51522e0aa787b1da927e3b6e1e33743c4b904b994a64b0ad802ade2a7882
2 parents 8483376 + 93ed34f commit 5af7bb0

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

types/src/v27/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
//! | getconnectioncount | version | |
105105
//! | getnettotals | version | |
106106
//! | getnetworkinfo | version + model | |
107-
//! | getnodeaddresses | version | TODO |
107+
//! | getnodeaddresses | version | |
108108
//! | getpeerinfo | version | |
109109
//! | listbanned | version | |
110110
//! | ping | returns nothing | |
@@ -249,9 +249,13 @@
249249
//! </details>
250250
251251
mod mining;
252+
mod network;
252253

253254
#[doc(inline)]
254-
pub use self::mining::{GetPrioritisedTransactions, PrioritisedTransaction};
255+
pub use self::{
256+
mining::{GetPrioritisedTransactions, PrioritisedTransaction},
257+
network::{GetNodeAddresses, NodeAddress},
258+
};
255259
#[doc(inline)]
256260
pub use crate::{
257261
v17::{
@@ -287,9 +291,9 @@ pub use crate::{
287291
},
288292
v18::{
289293
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
290-
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
291-
ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByLabel,
292-
ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
294+
AnalyzePsbtInputMissingError, DeriveAddresses, GetReceivedByLabel, ImportMulti,
295+
ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByLabel, ListReceivedByLabelError,
296+
ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt,
293297
},
294298
v19::{
295299
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine,

types/src/v27/network/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! The JSON-RPC API for Bitcoin Core `v27` - network.
4+
//!
5+
//! Types for methods found under the `== Network ==` section of the API docs.
6+
7+
use serde::{Deserialize, Serialize};
8+
9+
/// Result of JSON-RPC method `getnodeaddresses`.
10+
///
11+
/// > getnodeaddresses ( count "network" )
12+
/// >
13+
/// > Return known addresses, after filtering for quality and recency.
14+
/// > These can potentially be used to find new peers in the network.
15+
/// > The total number of addresses known to the node may be higher.
16+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
17+
#[serde(deny_unknown_fields)]
18+
pub struct GetNodeAddresses(pub Vec<NodeAddress>);
19+
20+
/// An item from the list returned by the JSON-RPC method `getnodeaddresses`.
21+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
22+
#[serde(deny_unknown_fields)]
23+
pub struct NodeAddress {
24+
/// Timestamp in seconds since epoch (Jan 1 1970 GMT) when the node was last seen.
25+
pub time: u64,
26+
/// The services offered.
27+
pub services: u64,
28+
/// The address of the node.
29+
pub address: String,
30+
/// The port of the node.
31+
pub port: u16,
32+
/// The network (ipv4, ipv6, onion, i2p, cjdns) the node connected through.
33+
pub network: String,
34+
}

types/src/v28/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ pub use crate::{
304304
},
305305
v18::{
306306
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
307-
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
308-
ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByLabel,
309-
ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
307+
AnalyzePsbtInputMissingError, DeriveAddresses, GetReceivedByLabel, ImportMulti,
308+
ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByLabel, ListReceivedByLabelError,
309+
ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt,
310310
},
311311
v19::{
312312
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine,
@@ -344,5 +344,5 @@ pub use crate::{
344344
GetTxOutSetInfo, GetTxOutSetInfoError, LastProcessedBlock, LastProcessedBlockError,
345345
LoadTxOutSet, LoadTxOutSetError, LoadWallet, PeerInfo, UnloadWallet,
346346
},
347-
v27::{GetPrioritisedTransactions, PrioritisedTransaction},
347+
v27::{GetNodeAddresses, GetPrioritisedTransactions, NodeAddress, PrioritisedTransaction},
348348
};

types/src/v29/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ pub use crate::{
302302
},
303303
v18::{
304304
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
305-
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
306-
ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByLabel,
307-
ListReceivedByLabelError, ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
305+
AnalyzePsbtInputMissingError, DeriveAddresses, GetReceivedByLabel, ImportMulti,
306+
ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByLabel, ListReceivedByLabelError,
307+
ListWalletDir, ListWalletDirWallet, UtxoUpdatePsbt,
308308
},
309309
v19::{
310310
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalancesMine,
@@ -342,7 +342,7 @@ pub use crate::{
342342
LastProcessedBlock, LastProcessedBlockError, LoadTxOutSet, LoadTxOutSetError, LoadWallet,
343343
PeerInfo, UnloadWallet,
344344
},
345-
v27::{GetPrioritisedTransactions, PrioritisedTransaction},
345+
v27::{GetNodeAddresses, GetPrioritisedTransactions, NodeAddress, PrioritisedTransaction},
346346
v28::{
347347
GetNetworkInfo, GetTransaction, Logging, SubmitPackage, SubmitPackageError,
348348
SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees,

0 commit comments

Comments
 (0)