Skip to content

Commit 825a9bc

Browse files
authored
Merge pull request #2147 from TheBlueMatt/2023-04-rgs-log-some
Add some trivial logging during RGS update processing.
2 parents 09f5e50 + 6897e5c commit 825a9bc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
//! # use lightning::util::logger::{Logger, Record};
5050
//! # struct FakeLogger {}
5151
//! # impl Logger for FakeLogger {
52-
//! # fn log(&self, record: &Record) { unimplemented!() }
52+
//! # fn log(&self, record: &Record) { }
5353
//! # }
5454
//! # let logger = FakeLogger {};
5555
//!

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use lightning::ln::msgs::{
1010
};
1111
use lightning::routing::gossip::NetworkGraph;
1212
use lightning::util::logger::Logger;
13-
use lightning::{log_warn, log_trace, log_given_level};
13+
use lightning::{log_debug, log_warn, log_trace, log_given_level, log_gossip};
1414
use lightning::util::ser::{BigSize, Readable};
1515
use lightning::io;
1616

@@ -58,6 +58,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
5858
mut read_cursor: &mut R,
5959
current_time_unix: Option<u64>
6060
) -> Result<u32, GraphSyncError> {
61+
log_trace!(self.logger, "Processing RGS data...");
6162
let mut prefix = [0u8; 4];
6263
read_cursor.read_exact(&mut prefix)?;
6364

@@ -110,6 +111,9 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
110111
let node_id_1 = node_ids[node_id_1_index.0 as usize];
111112
let node_id_2 = node_ids[node_id_2_index.0 as usize];
112113

114+
log_gossip!(self.logger, "Adding channel {} from RGS announcement at {}",
115+
short_channel_id, latest_seen_timestamp);
116+
113117
let announcement_result = network_graph.add_channel_from_partial_announcement(
114118
short_channel_id,
115119
backdated_timestamp as u64,
@@ -130,6 +134,8 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
130134
previous_scid = 0; // updates start at a new scid
131135

132136
let update_count: u32 = Readable::read(read_cursor)?;
137+
log_debug!(self.logger, "Processing RGS update from {} with {} nodes, {} channel announcements and {} channel updates.",
138+
latest_seen_timestamp, node_id_count, announcement_count, update_count);
133139
if update_count == 0 {
134140
return Ok(latest_seen_timestamp);
135141
}
@@ -217,6 +223,8 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
217223
continue;
218224
}
219225

226+
log_gossip!(self.logger, "Updating channel {} with flags {} from RGS announcement at {}",
227+
short_channel_id, channel_flags, latest_seen_timestamp);
220228
match network_graph.update_channel_unsigned(&synthetic_update) {
221229
Ok(_) => {},
222230
Err(LightningError { action: ErrorAction::IgnoreDuplicateGossip, .. }) => {},
@@ -230,6 +238,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
230238

231239
self.network_graph.set_last_rapid_gossip_sync_timestamp(latest_seen_timestamp);
232240
self.is_initial_sync_complete.store(true, Ordering::Release);
241+
log_trace!(self.logger, "Done processing RGS data from {}", latest_seen_timestamp);
233242
Ok(latest_seen_timestamp)
234243
}
235244
}

0 commit comments

Comments
 (0)