@@ -160,9 +160,11 @@ impl_writeable!(ChannelInfo, 0, {
160
160
announcement_message
161
161
} ) ;
162
162
163
- #[ derive( PartialEq ) ]
164
- struct NodeInfo {
165
- node_id : PublicKey ,
163
+ /// Details of a node, as stored in NetworkMap, and returned by Router::list_vertices
164
+ #[ derive( Clone , PartialEq ) ]
165
+ pub struct NodeInfo {
166
+ /// The node id
167
+ pub node_id : PublicKey ,
166
168
#[ cfg( feature = "non_bitcoin_chain_hash_routing" ) ]
167
169
channels : Vec < ( u64 , Sha256dHash ) > ,
168
170
#[ cfg( not( feature = "non_bitcoin_chain_hash_routing" ) ) ]
@@ -171,14 +173,19 @@ struct NodeInfo {
171
173
lowest_inbound_channel_fee_base_msat : u32 ,
172
174
lowest_inbound_channel_fee_proportional_millionths : u32 ,
173
175
174
- features : NodeFeatures ,
176
+ /// The node features
177
+ pub features : NodeFeatures ,
175
178
/// Unlike for channels, we may have a NodeInfo entry before having received a node_update.
176
179
/// Thus, we have to be able to capture "no update has been received", which we do with an
177
180
/// Option here.
178
- last_update : Option < u32 > ,
179
- rgb : [ u8 ; 3 ] ,
180
- alias : [ u8 ; 32 ] ,
181
- addresses : Vec < NetAddress > ,
181
+ /// The last tine a node announcement has been received
182
+ pub last_update : Option < u32 > ,
183
+ /// The custom node color
184
+ pub rgb : [ u8 ; 3 ] ,
185
+ /// The custom node alias
186
+ pub alias : [ u8 ; 32 ] ,
187
+ /// The network addresses
188
+ pub addresses : Vec < NetAddress > ,
182
189
//this is cached here so we can send out it later if required by route_init_sync
183
190
//keep an eye on this to see if the extra memory is a problem
184
191
announcement_message : Option < msgs:: NodeAnnouncement > ,
@@ -1089,6 +1096,17 @@ impl Router {
1089
1096
}
1090
1097
edges
1091
1098
}
1099
+
1100
+ /// Gets the list of announced nodes, in random order. See NodeInfo details field documentation for more information
1101
+ pub fn list_vertices ( & self ) -> Vec < NodeInfo > {
1102
+ let mut vertices = Vec :: new ( ) ;
1103
+ let network = self . network_map . read ( ) . unwrap ( ) ;
1104
+ vertices. reserve ( network. nodes . len ( ) ) ;
1105
+ for ( _, node) in network. nodes . iter ( ) {
1106
+ vertices. push ( ( * node) . clone ( ) ) ;
1107
+ }
1108
+ vertices
1109
+ }
1092
1110
}
1093
1111
1094
1112
#[ cfg( test) ]
0 commit comments