Remove println from lib.rs
[rapid-gossip-sync-server] / src / snapshot.rs
index c81cc35327715ea865cd62c24c1723611315c26f..63975becd74204e732dbbd50c659cf45786a4cac 100644 (file)
@@ -1,5 +1,6 @@
 use std::collections::HashMap;
 use std::fs;
+use std::ops::Deref;
 use std::os::unix::fs::symlink;
 use std::sync::Arc;
 use std::time::{Duration, SystemTime, UNIX_EPOCH};
@@ -10,13 +11,14 @@ use lightning::util::logger::Logger;
 use crate::config;
 use crate::config::cache_path;
 
-pub(crate) struct Snapshotter<L: Logger> {
-       network_graph: Arc<NetworkGraph<Arc<L>>>,
+pub(crate) struct Snapshotter<L: Deref + Clone> where L::Target: Logger {
+       network_graph: Arc<NetworkGraph<L>>,
+       logger: L
 }
 
-impl<L: Logger> Snapshotter<L> {
-       pub fn new(network_graph: Arc<NetworkGraph<Arc<L>>>) -> Self {
-               Self { network_graph }
+impl<L: Deref + Clone> Snapshotter<L> where L::Target: Logger {
+       pub fn new(network_graph: Arc<NetworkGraph<L>>, logger: L) -> Self {
+               Self { network_graph, logger }
        }
 
        pub(crate) async fn snapshot_gossip(&self) {
@@ -78,7 +80,7 @@ impl<L: Logger> Snapshotter<L> {
                                {
                                        println!("Calculating {}-day snapshot", day_range);
                                        // calculate the snapshot
-                                       let snapshot = super::serialize_delta(network_graph_clone, current_last_sync_timestamp.clone() as u32).await;
+                                       let snapshot = super::serialize_delta(network_graph_clone, current_last_sync_timestamp.clone() as u32, self.logger.clone()).await;
 
                                        // persist the snapshot and update the symlink
                                        let snapshot_filename = format!("snapshot__calculated-at:{}__range:{}-days__previous-sync:{}.lngossip", reference_timestamp, day_range, current_last_sync_timestamp);