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,
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;
pub(crate) struct GossipPersister<L: Deref> where L::Target: Logger {
gossip_persistence_receiver: mpsc::Receiver<GossipMessage>,
network_graph: Arc<NetworkGraph<L>>,
+ logger: L
}
impl<L: Deref> GossipPersister<L> where L::Target: Logger {
- pub fn new(network_graph: Arc<NetworkGraph<L>>) -> (Self, mpsc::Sender<GossipMessage>) {
+ pub fn new(network_graph: Arc<NetworkGraph<L>>, logger: L) -> (Self, mpsc::Sender<GossipMessage>) {
let (gossip_persistence_sender, gossip_persistence_receiver) =
mpsc::channel::<GossipMessage>(100);
(GossipPersister {
gossip_persistence_receiver,
- network_graph
+ network_graph,
+ logger
}, gossip_persistence_sender)
}
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();
}
}
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)
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!");
}
}