@@ -872,7 +872,7 @@ pub struct ChannelInfo {
872872 /// The timestamp when we received the announcement, if we are running with feature = "std"
873873 /// (which we can probably assume we are - no-std environments probably won't have a full
874874 /// network graph in memory!).
875- announcement_received_time : u64 ,
875+ pub announcement_received_time : u64 ,
876876}
877877
878878impl ChannelInfo {
@@ -1143,32 +1143,37 @@ pub struct NodeAnnouncementInfo {
11431143 /// May be invalid or malicious (eg control chars),
11441144 /// should not be exposed to the user.
11451145 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>,
11461152 /// An initial announcement of the node
11471153 /// Mostly redundant with the data we store in fields explicitly.
11481154 /// Everything else is useful only for sending out for initial routing sync.
11491155 /// Not stored if contains excess data to prevent DoS.
1150- pub announcement_message : Option < NodeAnnouncement >
1156+ pub announcement_message : Option < NodeAnnouncement > ,
11511157}
11521158
11531159impl NodeAnnouncementInfo {
11541160 /// Internet-level addresses via which one can connect to the node
11551161 pub fn addresses ( & self ) -> & [ SocketAddress ] {
11561162 self . announcement_message . as_ref ( )
11571163 . map ( |msg| msg. contents . addresses . as_slice ( ) )
1158- . unwrap_or_default ( )
1164+ . unwrap_or ( self . addresses . as_slice ( ) )
11591165 }
11601166}
11611167
11621168impl Writeable for NodeAnnouncementInfo {
11631169 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
1164- let empty_addresses = Vec :: < SocketAddress > :: new ( ) ;
11651170 write_tlv_fields ! ( writer, {
11661171 ( 0 , self . features, required) ,
11671172 ( 2 , self . last_update, required) ,
11681173 ( 4 , self . rgb, required) ,
11691174 ( 6 , self . alias, required) ,
11701175 ( 8 , self . announcement_message, option) ,
1171- ( 10 , empty_addresses , required_vec) , // Versions prior to 0.0.115 require this field
1176+ ( 10 , self . addresses , required_vec) , // Versions prior to 0.0.115 require this field
11721177 } ) ;
11731178 Ok ( ( ) )
11741179 }
@@ -1182,11 +1187,16 @@ impl Readable for NodeAnnouncementInfo {
11821187 ( 4 , rgb, required) ,
11831188 ( 6 , alias, required) ,
11841189 ( 8 , announcement_message, option) ,
1185- ( 10 , _addresses , optional_vec) , // deprecated, not used anymore
1190+ ( 10 , addresses , optional_vec) ,
11861191 } ) ;
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 } )
1192+ Ok ( Self {
1193+ features : features. 0 . unwrap ( ) ,
1194+ last_update : last_update. 0 . unwrap ( ) ,
1195+ rgb : rgb. 0 . unwrap ( ) ,
1196+ alias : alias. 0 . unwrap ( ) ,
1197+ addresses : addresses. unwrap_or ( Vec :: new ( ) ) ,
1198+ announcement_message,
1199+ } )
11901200 }
11911201}
11921202
@@ -1504,6 +1514,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
15041514 last_update : msg. timestamp ,
15051515 rgb : msg. rgb ,
15061516 alias : msg. alias ,
1517+ addresses : msg. addresses . clone ( ) ,
15071518 announcement_message : if should_relay { full_msg. cloned ( ) } else { None } ,
15081519 } ) ;
15091520
@@ -3453,6 +3464,7 @@ pub(crate) mod tests {
34533464 last_update : 0 ,
34543465 rgb : [ 0u8 ; 3 ] ,
34553466 alias : NodeAlias ( [ 0u8 ; 32 ] ) ,
3467+ addresses : announcement_message. contents . addresses . clone ( ) ,
34563468 announcement_message : Some ( announcement_message)
34573469 } ;
34583470
@@ -3487,8 +3499,8 @@ pub(crate) mod tests {
34873499 let old_ann_info_with_addresses = <Vec < u8 > >:: from_hex ( "3f0009000708a000080a51220204000000000403000000062000000000000000000000000000000000000000000000000000000000000000000a0505014104d2" ) . unwrap ( ) ;
34883500 let ann_info_with_addresses = NodeAnnouncementInfo :: read ( & mut old_ann_info_with_addresses. as_slice ( ) )
34893501 . 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( ) ) ;
3502+ // This serialized info has no announcement_message but its address field should still be considered
3503+ assert ! ( ! ann_info_with_addresses. addresses( ) . is_empty( ) ) ;
34923504 }
34933505
34943506 #[ test]
0 commit comments