Skip to content

Commit 477ddb5

Browse files
committed
Respond to Matt's additional comments.
1 parent 20cce05 commit 477ddb5

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

lightning-rapid-gossip-sync/src/processing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
4444
let mut prefix = [0u8; 4];
4545
read_cursor.read_exact(&mut prefix)?;
4646

47-
let _deserialize_unsigned = match prefix {
48-
GOSSIP_PREFIX => true,
47+
match prefix {
48+
GOSSIP_PREFIX => {},
4949
_ => {
5050
return Err(DecodeError::UnknownVersion.into());
5151
}
@@ -121,7 +121,7 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
121121
OptionalField::Present(tentative_default_htlc_maximum_msat)
122122
};
123123

124-
for _current_update_index in 0..update_count {
124+
for _ in 0..update_count {
125125
let scid_delta: BigSize = Readable::read(read_cursor)?;
126126
let short_channel_id = previous_scid
127127
.checked_add(scid_delta.0)

lightning/src/routing/network_graph.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use io;
3737
use prelude::*;
3838
use alloc::collections::{BTreeMap, btree_map::Entry as BtreeEntry};
3939
use core::{cmp, fmt};
40-
use sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
40+
use sync::{RwLock, RwLockReadGuard};
4141
use core::sync::atomic::{AtomicUsize, Ordering};
4242
use sync::Mutex;
4343
use core::ops::Deref;
@@ -1167,7 +1167,8 @@ impl NetworkGraph {
11671167

11681168
/// Update channel from partial announcement data received via rapid gossip sync
11691169
///
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)
11711172
///
11721173
/// All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields.
11731174
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 {
11881189
announcement_received_time: timestamp,
11891190
};
11901191

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)
11941193
}
11951194

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+
11971199
let node_id_a = channel_info.node_one.clone();
11981200
let node_id_b = channel_info.node_two.clone();
11991201

@@ -1288,20 +1290,18 @@ impl NetworkGraph {
12881290
}
12891291

12901292
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+
};
13011303

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)
13051305
}
13061306

13071307
/// Close a channel if a corresponding HTLC fail was sent.

0 commit comments

Comments
 (0)