@@ -872,7 +872,7 @@ pub struct ChannelInfo {
872
872
/// The timestamp when we received the announcement, if we are running with feature = "std"
873
873
/// (which we can probably assume we are - no-std environments probably won't have a full
874
874
/// network graph in memory!).
875
- announcement_received_time : u64 ,
875
+ pub announcement_received_time : u64 ,
876
876
}
877
877
878
878
impl ChannelInfo {
@@ -1143,19 +1143,25 @@ pub struct NodeAnnouncementInfo {
1143
1143
/// May be invalid or malicious (eg control chars),
1144
1144
/// should not be exposed to the user.
1145
1145
pub alias : NodeAlias ,
1146
+
1147
+ /// Internet-level addresses via which one can connect to the node
1148
+ pub addresses : Vec < SocketAddress > ,
1149
+
1150
+ /// List of addresses on which this node is reachable
1151
+ // pub addresses: Vec<SocketAddress>,
1146
1152
/// An initial announcement of the node
1147
1153
/// Mostly redundant with the data we store in fields explicitly.
1148
1154
/// Everything else is useful only for sending out for initial routing sync.
1149
1155
/// Not stored if contains excess data to prevent DoS.
1150
- pub announcement_message : Option < NodeAnnouncement >
1156
+ pub announcement_message : Option < NodeAnnouncement > ,
1151
1157
}
1152
1158
1153
1159
impl NodeAnnouncementInfo {
1154
1160
/// Internet-level addresses via which one can connect to the node
1155
1161
pub fn addresses ( & self ) -> & [ SocketAddress ] {
1156
1162
self . announcement_message . as_ref ( )
1157
1163
. map ( |msg| msg. contents . addresses . as_slice ( ) )
1158
- . unwrap_or_default ( )
1164
+ . unwrap_or ( self . addresses . as_slice ( ) )
1159
1165
}
1160
1166
}
1161
1167
@@ -1168,7 +1174,7 @@ impl Writeable for NodeAnnouncementInfo {
1168
1174
( 4 , self . rgb, required) ,
1169
1175
( 6 , self . alias, required) ,
1170
1176
( 8 , self . announcement_message, option) ,
1171
- ( 10 , empty_addresses , required_vec) , // Versions prior to 0.0.115 require this field
1177
+ ( 10 , self . addresses , required_vec) , // Versions prior to 0.0.115 require this field
1172
1178
} ) ;
1173
1179
Ok ( ( ) )
1174
1180
}
@@ -1182,11 +1188,16 @@ impl Readable for NodeAnnouncementInfo {
1182
1188
( 4 , rgb, required) ,
1183
1189
( 6 , alias, required) ,
1184
1190
( 8 , announcement_message, option) ,
1185
- ( 10 , _addresses , optional_vec) , // deprecated, not used anymore
1191
+ ( 10 , addresses , optional_vec) ,
1186
1192
} ) ;
1187
- let _: Option < Vec < SocketAddress > > = _addresses;
1188
- Ok ( Self { features : features. 0 . unwrap ( ) , last_update : last_update. 0 . unwrap ( ) , rgb : rgb. 0 . unwrap ( ) ,
1189
- alias : alias. 0 . unwrap ( ) , announcement_message } )
1193
+ Ok ( Self {
1194
+ features : features. 0 . unwrap ( ) ,
1195
+ last_update : last_update. 0 . unwrap ( ) ,
1196
+ rgb : rgb. 0 . unwrap ( ) ,
1197
+ alias : alias. 0 . unwrap ( ) ,
1198
+ addresses : addresses. unwrap_or ( Vec :: new ( ) ) ,
1199
+ announcement_message,
1200
+ } )
1190
1201
}
1191
1202
}
1192
1203
@@ -1504,6 +1515,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1504
1515
last_update : msg. timestamp ,
1505
1516
rgb : msg. rgb ,
1506
1517
alias : msg. alias ,
1518
+ addresses : msg. addresses . clone ( ) ,
1507
1519
announcement_message : if should_relay { full_msg. cloned ( ) } else { None } ,
1508
1520
} ) ;
1509
1521
@@ -3453,6 +3465,7 @@ pub(crate) mod tests {
3453
3465
last_update : 0 ,
3454
3466
rgb : [ 0u8 ; 3 ] ,
3455
3467
alias : NodeAlias ( [ 0u8 ; 32 ] ) ,
3468
+ addresses : announcement_message. contents . addresses . clone ( ) ,
3456
3469
announcement_message : Some ( announcement_message)
3457
3470
} ;
3458
3471
@@ -3487,8 +3500,8 @@ pub(crate) mod tests {
3487
3500
let old_ann_info_with_addresses = <Vec < u8 > >:: from_hex ( "3f0009000708a000080a51220204000000000403000000062000000000000000000000000000000000000000000000000000000000000000000a0505014104d2" ) . unwrap ( ) ;
3488
3501
let ann_info_with_addresses = NodeAnnouncementInfo :: read ( & mut old_ann_info_with_addresses. as_slice ( ) )
3489
3502
. expect ( "to be able to read an old NodeAnnouncementInfo with addresses" ) ;
3490
- // This serialized info has an address field but no announcement_message, therefore the addresses returned by our function will still be empty
3491
- assert ! ( ann_info_with_addresses. addresses( ) . is_empty( ) ) ;
3503
+ // This serialized info has no announcement_message but its address field should still be considered
3504
+ assert ! ( ! ann_info_with_addresses. addresses( ) . is_empty( ) ) ;
3492
3505
}
3493
3506
3494
3507
#[ test]
0 commit comments