From: Arik Sosman Date: Thu, 3 Aug 2023 01:19:13 +0000 (-0700) Subject: Remove println from persistence.rs X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=3a7938605a1968e7d0bae41f63af735e304671ae;p=rapid-gossip-sync-server Remove println from persistence.rs --- diff --git a/src/lib.rs b/src/lib.rs index 41057d3..b6281bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ impl RapidSyncProcessor where L::Ta let (sync_completion_sender, mut sync_completion_receiver) = mpsc::channel::<()>(1); if config::DOWNLOAD_NEW_GOSSIP { - let (mut persister, persistence_sender) = GossipPersister::new(Arc::clone(&self.network_graph)); + let (mut persister, persistence_sender) = GossipPersister::new(self.network_graph.clone(), self.logger.clone()); log_info!(self.logger, "Starting gossip download"); tokio::spawn(tracking::download_gossip(persistence_sender, sync_completion_sender, diff --git a/src/persistence.rs b/src/persistence.rs index e2d9eb0..f638894 100644 --- a/src/persistence.rs +++ b/src/persistence.rs @@ -3,6 +3,7 @@ use std::io::{BufWriter, Write}; use std::ops::Deref; use std::sync::Arc; use std::time::{Duration, Instant}; +use lightning::log_info; use lightning::routing::gossip::NetworkGraph; use lightning::util::logger::Logger; use lightning::util::ser::Writeable; @@ -17,15 +18,17 @@ const POSTGRES_INSERT_TIMEOUT: Duration = Duration::from_secs(15); pub(crate) struct GossipPersister where L::Target: Logger { gossip_persistence_receiver: mpsc::Receiver, network_graph: Arc>, + logger: L } impl GossipPersister where L::Target: Logger { - pub fn new(network_graph: Arc>) -> (Self, mpsc::Sender) { + pub fn new(network_graph: Arc>, logger: L) -> (Self, mpsc::Sender) { let (gossip_persistence_sender, gossip_persistence_receiver) = mpsc::channel::(100); (GossipPersister { gossip_persistence_receiver, - network_graph + network_graph, + logger }, gossip_persistence_sender) } @@ -101,7 +104,7 @@ impl GossipPersister where L::Target: Logger { i += 1; // count the persisted gossip messages if latest_persistence_log.elapsed().as_secs() >= 60 { - println!("Persisting gossip message #{}", i); + log_info!(self.logger, "Persisting gossip message #{}", i); latest_persistence_log = Instant::now(); } @@ -179,7 +182,7 @@ impl GossipPersister where L::Target: Logger { } fn persist_network_graph(&self) { - println!("Caching network graph…"); + log_info!(self.logger, "Caching network graph…"); let cache_path = config::network_graph_cache_path(); let file = OpenOptions::new() .create(true) @@ -191,6 +194,6 @@ impl GossipPersister where L::Target: Logger { let mut writer = BufWriter::new(file); self.network_graph.write(&mut writer).unwrap(); writer.flush().unwrap(); - println!("Cached network graph!"); + log_info!(self.logger, "Cached network graph!"); } }