Skip to content

Commit 89be625

Browse files
authored
Merge pull request #790 from bmancini55/sync_complete
Interpret sync_complete in reply_channel_range
2 parents b67ec5a + 77690fa commit 89be625

File tree

2 files changed

+9
-37
lines changed

2 files changed

+9
-37
lines changed

lightning/src/ln/msgs.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,8 @@ pub struct ReplyChannelRange {
602602
pub first_blocknum: u32,
603603
/// The number of blocks included in the range of the reply
604604
pub number_of_blocks: u32,
605-
/// Indicates if the query recipient maintains up-to-date channel
606-
/// information for the chain_hash
607-
pub full_information: bool,
605+
/// True when this is the final reply for a query
606+
pub sync_complete: bool,
608607
/// The short_channel_ids in the channel range
609608
pub short_channel_ids: Vec<u64>,
610609
}
@@ -1727,7 +1726,7 @@ impl Readable for ReplyChannelRange {
17271726
let chain_hash: BlockHash = Readable::read(r)?;
17281727
let first_blocknum: u32 = Readable::read(r)?;
17291728
let number_of_blocks: u32 = Readable::read(r)?;
1730-
let full_information: bool = Readable::read(r)?;
1729+
let sync_complete: bool = Readable::read(r)?;
17311730

17321731
// We expect the encoding_len to always includes the 1-byte
17331732
// encoding_type and that short_channel_ids are 8-bytes each
@@ -1755,7 +1754,7 @@ impl Readable for ReplyChannelRange {
17551754
chain_hash,
17561755
first_blocknum,
17571756
number_of_blocks,
1758-
full_information,
1757+
sync_complete,
17591758
short_channel_ids
17601759
})
17611760
}
@@ -1768,7 +1767,7 @@ impl Writeable for ReplyChannelRange {
17681767
self.chain_hash.write(w)?;
17691768
self.first_blocknum.write(w)?;
17701769
self.number_of_blocks.write(w)?;
1771-
self.full_information.write(w)?;
1770+
self.sync_complete.write(w)?;
17721771

17731772
encoding_len.write(w)?;
17741773
(EncodingType::Uncompressed as u8).write(w)?;
@@ -2569,7 +2568,7 @@ mod tests {
25692568
chain_hash: expected_chain_hash,
25702569
first_blocknum: 756230,
25712570
number_of_blocks: 1500,
2572-
full_information: true,
2571+
sync_complete: true,
25732572
short_channel_ids: vec![0x000000000000008e, 0x0000000000003c69, 0x000000000045a6c4],
25742573
};
25752574

@@ -2582,7 +2581,7 @@ mod tests {
25822581
assert_eq!(reply_channel_range.chain_hash, expected_chain_hash);
25832582
assert_eq!(reply_channel_range.first_blocknum, 756230);
25842583
assert_eq!(reply_channel_range.number_of_blocks, 1500);
2585-
assert_eq!(reply_channel_range.full_information, true);
2584+
assert_eq!(reply_channel_range.sync_complete, true);
25862585
assert_eq!(reply_channel_range.short_channel_ids[0], 0x000000000000008e);
25872586
assert_eq!(reply_channel_range.short_channel_ids[1], 0x0000000000003c69);
25882587
assert_eq!(reply_channel_range.short_channel_ids[2], 0x000000000045a6c4);

lightning/src/routing/network_graph.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,7 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
264264
/// does not match our chain_hash will be rejected when the announcement is
265265
/// processed.
266266
fn handle_reply_channel_range(&self, their_node_id: &PublicKey, msg: ReplyChannelRange) -> Result<(), LightningError> {
267-
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(),);
268-
269-
// Validate that the remote node maintains up-to-date channel
270-
// information for chain_hash. Some nodes use the full_information
271-
// flag to indicate multi-part messages so we must check whether
272-
// we received SCIDs as well.
273-
if !msg.full_information && msg.short_channel_ids.len() == 0 {
274-
return Err(LightningError {
275-
err: String::from("Received reply_channel_range with no information available"),
276-
action: ErrorAction::IgnoreError,
277-
});
278-
}
267+
log_debug!(self.logger, "Handling reply_channel_range peer={}, first_blocknum={}, number_of_blocks={}, sync_complete={}, scids={}", log_pubkey!(their_node_id), msg.first_blocknum, msg.number_of_blocks, msg.sync_complete, msg.short_channel_ids.len(),);
279268

280269
log_debug!(self.logger, "Sending query_short_channel_ids peer={}, batch_size={}", log_pubkey!(their_node_id), msg.short_channel_ids.len());
281270
let mut pending_events = self.pending_events.lock().unwrap();
@@ -2015,7 +2004,7 @@ mod tests {
20152004
{
20162005
let result = net_graph_msg_handler.handle_reply_channel_range(&node_id_1, ReplyChannelRange {
20172006
chain_hash,
2018-
full_information: true,
2007+
sync_complete: true,
20192008
first_blocknum: 0,
20202009
number_of_blocks: 2000,
20212010
short_channel_ids: vec![
@@ -2048,22 +2037,6 @@ mod tests {
20482037
_ => panic!("expected MessageSendEvent::SendShortIdsQuery"),
20492038
}
20502039
}
2051-
2052-
// Test receipt of a reply that indicates the remote node does not maintain up-to-date
2053-
// information for the chain_hash. Because of discrepancies in implementation we use
2054-
// full_information=false and short_channel_ids=[] as the signal.
2055-
{
2056-
// Handle the reply indicating the peer was unable to fulfill our request.
2057-
let result = net_graph_msg_handler.handle_reply_channel_range(&node_id_1, ReplyChannelRange {
2058-
chain_hash,
2059-
full_information: false,
2060-
first_blocknum: 1000,
2061-
number_of_blocks: 100,
2062-
short_channel_ids: vec![],
2063-
});
2064-
assert!(result.is_err());
2065-
assert_eq!(result.err().unwrap().err, "Received reply_channel_range with no information available");
2066-
}
20672040
}
20682041

20692042
#[test]

0 commit comments

Comments
 (0)