X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Fnetwork_graph.rs;h=44ee21ab8270b73c02e516112d75dd6126f0c930;hb=1809ef199e4c68516b1d4bf1664c63f88d4ef29a;hp=34859cf07c462311ee1623bae195e7527ddb4205;hpb=44ba52ccf10bb0362ed2964b66ec2ae51e388161;p=rust-lightning diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 34859cf0..44ee21ab 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -30,7 +30,7 @@ use ln::msgs; use util::ser::{Writeable, Readable, Writer}; use util::logger::Logger; use util::events::{MessageSendEvent, MessageSendEventsProvider}; -use util::scid_utils::{block_from_scid, scid_from_parts}; +use util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK}; use std::{cmp, fmt}; use std::sync::{RwLock, RwLockReadGuard}; @@ -329,11 +329,11 @@ impl RoutingMessageHandler for N let network_graph = self.network_graph.read().unwrap(); - let start_scid = scid_from_parts(msg.first_blocknum, 0, 0); + let start_scid = scid_from_parts(msg.first_blocknum as u64, 0, 0); // We receive valid queries with end_blocknum that would overflow SCID conversion. // Manually cap the ending block to avoid this overflow. - let exclusive_end_scid = scid_from_parts(cmp::min(msg.end_blocknum(), 0xffffff), 0, 0); + let exclusive_end_scid = scid_from_parts(cmp::min(msg.end_blocknum() as u64, MAX_SCID_BLOCK), 0, 0); // Per spec, we must reply to a query. Send an empty message when things are invalid. if msg.chain_hash != network_graph.genesis_hash || start_scid.is_err() || exclusive_end_scid.is_err() { @@ -369,9 +369,8 @@ impl RoutingMessageHandler for N drop(network_graph); let mut pending_events = self.pending_events.lock().unwrap(); - let mut batch_index = 0; let batch_count = batches.len(); - for batch in batches.into_iter() { + for (batch_index, batch) in batches.into_iter().enumerate() { // Per spec, the initial first_blocknum needs to be <= the query's first_blocknum. // Use the query's values since we don't use pre-processed reply ranges. let first_blocknum = if batch_index == 0 { @@ -409,8 +408,6 @@ impl RoutingMessageHandler for N short_channel_ids: batch, } }); - - batch_index += 1; } Ok(())