@@ -37,7 +37,7 @@ use io;
37
37
use prelude:: * ;
38
38
use alloc:: collections:: { BTreeMap , btree_map:: Entry as BtreeEntry } ;
39
39
use core:: { cmp, fmt} ;
40
- use sync:: { RwLock , RwLockReadGuard , RwLockWriteGuard } ;
40
+ use sync:: { RwLock , RwLockReadGuard } ;
41
41
use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
42
42
use sync:: Mutex ;
43
43
use core:: ops:: Deref ;
@@ -1167,7 +1167,8 @@ impl NetworkGraph {
1167
1167
1168
1168
/// Update channel from partial announcement data received via rapid gossip sync
1169
1169
///
1170
- /// `timestamp: u64`: Timestamp the announcement was originally received.
1170
+ /// `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the
1171
+ /// rapid gossip sync server)
1171
1172
///
1172
1173
/// All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields.
1173
1174
pub fn add_channel_from_partial_announcement ( & self , short_channel_id : u64 , timestamp : u64 , features : ChannelFeatures , node_id_1 : PublicKey , node_id_2 : PublicKey ) -> Result < ( ) , LightningError > {
@@ -1188,12 +1189,13 @@ impl NetworkGraph {
1188
1189
announcement_received_time : timestamp,
1189
1190
} ;
1190
1191
1191
- let channels = self . channels . write ( ) . unwrap ( ) ;
1192
- let nodes = self . nodes . write ( ) . unwrap ( ) ;
1193
- Self :: add_channel_between_nodes ( channels, nodes, short_channel_id, channel_info, None )
1192
+ self . add_channel_between_nodes ( short_channel_id, channel_info, None )
1194
1193
}
1195
1194
1196
- fn add_channel_between_nodes ( mut channels : RwLockWriteGuard < BTreeMap < u64 , ChannelInfo > > , mut nodes : RwLockWriteGuard < BTreeMap < NodeId , NodeInfo > > , short_channel_id : u64 , channel_info : ChannelInfo , utxo_value : Option < u64 > ) -> Result < ( ) , LightningError > {
1195
+ fn add_channel_between_nodes ( & self , short_channel_id : u64 , channel_info : ChannelInfo , utxo_value : Option < u64 > ) -> Result < ( ) , LightningError > {
1196
+ let mut channels = self . channels . write ( ) . unwrap ( ) ;
1197
+ let mut nodes = self . nodes . write ( ) . unwrap ( ) ;
1198
+
1197
1199
let node_id_a = channel_info. node_one . clone ( ) ;
1198
1200
let node_id_b = channel_info. node_two . clone ( ) ;
1199
1201
@@ -1288,20 +1290,18 @@ impl NetworkGraph {
1288
1290
}
1289
1291
1290
1292
let chan_info = ChannelInfo {
1291
- features : msg. features . clone ( ) ,
1292
- node_one : NodeId :: from_pubkey ( & msg. node_id_1 ) ,
1293
- one_to_two : None ,
1294
- node_two : NodeId :: from_pubkey ( & msg. node_id_2 ) ,
1295
- two_to_one : None ,
1296
- capacity_sats : utxo_value,
1297
- announcement_message : if msg. excess_data . len ( ) <= MAX_EXCESS_BYTES_FOR_RELAY
1298
- { full_msg. cloned ( ) } else { None } ,
1299
- announcement_received_time,
1300
- } ;
1293
+ features : msg. features . clone ( ) ,
1294
+ node_one : NodeId :: from_pubkey ( & msg. node_id_1 ) ,
1295
+ one_to_two : None ,
1296
+ node_two : NodeId :: from_pubkey ( & msg. node_id_2 ) ,
1297
+ two_to_one : None ,
1298
+ capacity_sats : utxo_value,
1299
+ announcement_message : if msg. excess_data . len ( ) <= MAX_EXCESS_BYTES_FOR_RELAY
1300
+ { full_msg. cloned ( ) } else { None } ,
1301
+ announcement_received_time,
1302
+ } ;
1301
1303
1302
- let channels = self . channels . write ( ) . unwrap ( ) ;
1303
- let nodes = self . nodes . write ( ) . unwrap ( ) ;
1304
- Self :: add_channel_between_nodes ( channels, nodes, msg. short_channel_id , chan_info, utxo_value)
1304
+ self . add_channel_between_nodes ( msg. short_channel_id , chan_info, utxo_value)
1305
1305
}
1306
1306
1307
1307
/// Close a channel if a corresponding HTLC fail was sent.
0 commit comments