@@ -246,10 +246,8 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
246
246
/// stateless, it does not validate the sequencing of replies for multi-
247
247
/// reply ranges. It does not validate whether the reply(ies) cover the
248
248
/// queried range. It also does not filter SCIDs to only those in the
249
- /// original query range. In the event of a failure, we may have received
250
- /// some channel information. Before trying with another peer, the
251
- /// caller should update its set of SCIDs that need to be queried.
252
- fn handle_reply_channel_range ( & self , their_node_id : & PublicKey , msg : & ReplyChannelRange ) -> Result < ( ) , LightningError > {
249
+ /// original query range.
250
+ fn handle_reply_channel_range ( & self , their_node_id : & PublicKey , msg : ReplyChannelRange ) -> Result < ( ) , LightningError > {
253
251
log_debug ! ( self . logger, "Handling reply_channel_range peer={}, first_blocknum={}, number_of_blocks={}, full_information={}, scids={}" , log_pubkey!( their_node_id) , msg. first_blocknum, msg. number_of_blocks, msg. full_information, msg. short_channel_ids. len( ) , ) ;
254
252
255
253
// Validate that the remote node maintains up-to-date channel
@@ -263,20 +261,13 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
263
261
} ) ;
264
262
}
265
263
266
- // Copy the SCIDs into a new vector to be sent in the SCID query
267
- let scid_size = msg. short_channel_ids . len ( ) ;
268
- let mut short_channel_ids: Vec < u64 > = Vec :: with_capacity ( scid_size) ;
269
- for scid in msg. short_channel_ids . iter ( ) {
270
- short_channel_ids. push ( scid. clone ( ) ) ;
271
- }
272
-
273
- log_debug ! ( self . logger, "Sending query_short_channel_ids peer={}, batch_size={}" , log_pubkey!( their_node_id) , scid_size) ;
264
+ log_debug ! ( self . logger, "Sending query_short_channel_ids peer={}, batch_size={}" , log_pubkey!( their_node_id) , msg. short_channel_ids. len( ) ) ;
274
265
let mut pending_events = self . pending_events . lock ( ) . unwrap ( ) ;
275
266
pending_events. push ( events:: MessageSendEvent :: SendShortIdsQuery {
276
267
node_id : their_node_id. clone ( ) ,
277
268
msg : QueryShortChannelIds {
278
- chain_hash : msg. chain_hash . clone ( ) ,
279
- short_channel_ids,
269
+ chain_hash : msg. chain_hash ,
270
+ short_channel_ids : msg . short_channel_ids ,
280
271
}
281
272
} ) ;
282
273
@@ -287,7 +278,7 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
287
278
/// gossip messages. In the event of a failure, we may have received
288
279
/// some channel information. Before trying with another peer, the
289
280
/// caller should update its set of SCIDs that need to be queried.
290
- fn handle_reply_short_channel_ids_end ( & self , their_node_id : & PublicKey , msg : & ReplyShortChannelIdsEnd ) -> Result < ( ) , LightningError > {
281
+ fn handle_reply_short_channel_ids_end ( & self , their_node_id : & PublicKey , msg : ReplyShortChannelIdsEnd ) -> Result < ( ) , LightningError > {
291
282
log_debug ! ( self . logger, "Handling reply_short_channel_ids_end peer={}, full_information={}" , log_pubkey!( their_node_id) , msg. full_information) ;
292
283
293
284
// If the remote node does not have up-to-date information for the
@@ -303,21 +294,15 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
303
294
Ok ( ( ) )
304
295
}
305
296
306
- /// There are potential DoS vectors when handling inbound queries.
307
- /// Handling requests with first_blocknum very far away may trigger repeated
308
- /// disk I/O if the NetworkGraph is not fully in-memory.
309
- fn handle_query_channel_range ( & self , _their_node_id : & PublicKey , _msg : & QueryChannelRange ) -> Result < ( ) , LightningError > {
297
+ fn handle_query_channel_range ( & self , _their_node_id : & PublicKey , _msg : QueryChannelRange ) -> Result < ( ) , LightningError > {
310
298
// TODO
311
299
Err ( LightningError {
312
300
err : String :: from ( "Not implemented" ) ,
313
301
action : ErrorAction :: IgnoreError ,
314
302
} )
315
303
}
316
304
317
- /// There are potential DoS vectors when handling inbound queries.
318
- /// Handling requests with first_blocknum very far away may trigger repeated
319
- /// disk I/O if the NetworkGraph is not fully in-memory.
320
- fn handle_query_short_channel_ids ( & self , _their_node_id : & PublicKey , _msg : & QueryShortChannelIds ) -> Result < ( ) , LightningError > {
305
+ fn handle_query_short_channel_ids ( & self , _their_node_id : & PublicKey , _msg : QueryShortChannelIds ) -> Result < ( ) , LightningError > {
321
306
// TODO
322
307
Err ( LightningError {
323
308
err : String :: from ( "Not implemented" ) ,
@@ -1982,7 +1967,7 @@ mod tests {
1982
1967
// matching the SCIDs in the reply
1983
1968
{
1984
1969
// Handle a single successful reply that encompasses the queried channel range
1985
- let result = net_graph_msg_handler. handle_reply_channel_range ( & node_id_1, & ReplyChannelRange {
1970
+ let result = net_graph_msg_handler. handle_reply_channel_range ( & node_id_1, ReplyChannelRange {
1986
1971
chain_hash,
1987
1972
full_information : true ,
1988
1973
first_blocknum : 0 ,
@@ -2023,7 +2008,7 @@ mod tests {
2023
2008
// full_information=false and short_channel_ids=[] as the signal.
2024
2009
{
2025
2010
// Handle the reply indicating the peer was unable to fulfill our request.
2026
- let result = net_graph_msg_handler. handle_reply_channel_range ( & node_id_1, & ReplyChannelRange {
2011
+ let result = net_graph_msg_handler. handle_reply_channel_range ( & node_id_1, ReplyChannelRange {
2027
2012
chain_hash,
2028
2013
full_information : false ,
2029
2014
first_blocknum : 1000 ,
@@ -2045,7 +2030,7 @@ mod tests {
2045
2030
2046
2031
// Test receipt of a successful reply
2047
2032
{
2048
- let result = net_graph_msg_handler. handle_reply_short_channel_ids_end ( & node_id, & ReplyShortChannelIdsEnd {
2033
+ let result = net_graph_msg_handler. handle_reply_short_channel_ids_end ( & node_id, ReplyShortChannelIdsEnd {
2049
2034
chain_hash,
2050
2035
full_information : true ,
2051
2036
} ) ;
@@ -2055,7 +2040,7 @@ mod tests {
2055
2040
// Test receipt of a reply that indicates the peer does not maintain up-to-date information
2056
2041
// for the chain_hash requested in the query.
2057
2042
{
2058
- let result = net_graph_msg_handler. handle_reply_short_channel_ids_end ( & node_id, & ReplyShortChannelIdsEnd {
2043
+ let result = net_graph_msg_handler. handle_reply_short_channel_ids_end ( & node_id, ReplyShortChannelIdsEnd {
2059
2044
chain_hash,
2060
2045
full_information : false ,
2061
2046
} ) ;
@@ -2072,7 +2057,7 @@ mod tests {
2072
2057
2073
2058
let chain_hash = genesis_block ( Network :: Testnet ) . header . block_hash ( ) ;
2074
2059
2075
- let result = net_graph_msg_handler. handle_query_channel_range ( & node_id, & QueryChannelRange {
2060
+ let result = net_graph_msg_handler. handle_query_channel_range ( & node_id, QueryChannelRange {
2076
2061
chain_hash,
2077
2062
first_blocknum : 0 ,
2078
2063
number_of_blocks : 0xffff_ffff ,
@@ -2088,7 +2073,7 @@ mod tests {
2088
2073
2089
2074
let chain_hash = genesis_block ( Network :: Testnet ) . header . block_hash ( ) ;
2090
2075
2091
- let result = net_graph_msg_handler. handle_query_short_channel_ids ( & node_id, & QueryShortChannelIds {
2076
+ let result = net_graph_msg_handler. handle_query_short_channel_ids ( & node_id, QueryShortChannelIds {
2092
2077
chain_hash,
2093
2078
short_channel_ids : vec ! [ 0x0003e8_000000_0000 ] ,
2094
2079
} ) ;
0 commit comments