X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-background-processor%2Fsrc%2Flib.rs;h=1d0d787388e43d8e5d2564cd54f16ebff4b127c7;hb=3c02e507d67f83469b6e533e551d1f08e3915343;hp=f7f1296b98e66e737c6c81283a8a7e459a7b8160;hpb=5c6e36727c6a16bec20a9af74af950e7dfb31061;p=rust-lightning diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index f7f1296b..1d0d7873 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -33,7 +33,9 @@ use lightning::routing::gossip::{NetworkGraph, P2PGossipSync}; use lightning::routing::utxo::UtxoLookup; use lightning::routing::router::Router; use lightning::routing::scoring::{Score, WriteableScore}; -use lightning::util::events::{Event, EventHandler, EventsProvider, PathFailure}; +use lightning::util::events::{Event, PathFailure}; +#[cfg(feature = "std")] +use lightning::util::events::{EventHandler, EventsProvider}; use lightning::util::logger::Logger; use lightning::util::persist::Persister; use lightning_rapid_gossip_sync::RapidGossipSync; @@ -162,7 +164,7 @@ where U::Target: UtxoLookup, L::Target: Logger { } } -/// (C-not exported) as the bindings concretize everything and have constructors for us +/// This is not exported to bindings users as the bindings concretize everything and have constructors for us impl>, G: Deref>, U: Deref, L: Deref> GossipSync, G, U, L> where @@ -175,7 +177,7 @@ where } } -/// (C-not exported) as the bindings concretize everything and have constructors for us +/// This is not exported to bindings users as the bindings concretize everything and have constructors for us impl<'a, R: Deref>, G: Deref>, L: Deref> GossipSync< &P2PGossipSync, @@ -193,7 +195,7 @@ where } } -/// (C-not exported) as the bindings concretize everything and have constructors for us +/// This is not exported to bindings users as the bindings concretize everything and have constructors for us impl<'a, L: Deref> GossipSync< &P2PGossipSync<&'a NetworkGraph, &'a (dyn UtxoLookup + Send + Sync), L>, @@ -347,9 +349,9 @@ macro_rules! define_run_body { log_error!($logger, "Error: Failed to persist network graph, check your disk and permissions {}", e) } - last_prune_call = $get_timer(NETWORK_PRUNE_TIMER); have_pruned = true; } + last_prune_call = $get_timer(NETWORK_PRUNE_TIMER); } if $timer_elapsed(&mut last_scorer_persist_call, SCORER_PERSIST_TIMER) { @@ -755,7 +757,7 @@ mod tests { impl Persister { fn new(data_dir: String) -> Self { - let filesystem_persister = FilesystemPersister::new(data_dir.clone()); + let filesystem_persister = FilesystemPersister::new(data_dir); Self { graph_error: None, graph_persistence_notifier: None, manager_error: None, scorer_error: None, filesystem_persister } } @@ -822,7 +824,7 @@ mod tests { } fn expect(&mut self, expectation: TestResult) { - self.event_expectations.get_or_insert_with(|| VecDeque::new()).push_back(expectation); + self.event_expectations.get_or_insert_with(VecDeque::new).push_back(expectation); } } @@ -1224,7 +1226,7 @@ mod tests { // Set up a background event handler for SpendableOutputs events. let (sender, receiver) = std::sync::mpsc::sync_channel(1); let event_handler = move |event: Event| match event { - Event::SpendableOutputs { .. } => sender.send(event.clone()).unwrap(), + Event::SpendableOutputs { .. } => sender.send(event).unwrap(), Event::ChannelReady { .. } => {}, Event::ChannelClosed { .. } => {}, _ => panic!("Unexpected event: {:?}", event), @@ -1272,7 +1274,7 @@ mod tests { let nodes = create_nodes(2, "test_not_pruning_network_graph_until_graph_sync_completion".to_string()); let data_dir = nodes[0].persister.get_data_dir(); let (sender, receiver) = std::sync::mpsc::sync_channel(1); - let persister = Arc::new(Persister::new(data_dir.clone()).with_graph_persistence_notifier(sender)); + let persister = Arc::new(Persister::new(data_dir).with_graph_persistence_notifier(sender)); let network_graph = nodes[0].network_graph.clone(); let features = ChannelFeatures::empty(); network_graph.add_channel_from_partial_announcement(42, 53, features, nodes[0].node.get_our_node_id(), nodes[1].node.get_our_node_id()) @@ -1315,7 +1317,7 @@ mod tests { // this should have added two channels assert_eq!(network_graph.read_only().channels().len(), 3); - let _ = receiver + receiver .recv_timeout(Duration::from_secs(super::FIRST_NETWORK_PRUNE_TIMER * 5)) .expect("Network graph not pruned within deadline"); @@ -1342,7 +1344,7 @@ mod tests { let nodes = create_nodes(1, "test_payment_path_scoring".to_string()); let data_dir = nodes[0].persister.get_data_dir(); - let persister = Arc::new(Persister::new(data_dir.clone())); + let persister = Arc::new(Persister::new(data_dir)); let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].no_gossip_sync(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone())); let scored_scid = 4242; @@ -1367,7 +1369,6 @@ mod tests { failure: PathFailure::OnPath { network_update: None }, path: path.clone(), short_channel_id: Some(scored_scid), - retry: None, }); let event = receiver .recv_timeout(Duration::from_secs(EVENT_DEADLINE)) @@ -1387,7 +1388,6 @@ mod tests { failure: PathFailure::OnPath { network_update: None }, path: path.clone(), short_channel_id: None, - retry: None, }); let event = receiver .recv_timeout(Duration::from_secs(EVENT_DEADLINE)) @@ -1429,7 +1429,7 @@ mod tests { nodes[0].node.push_pending_event(Event::ProbeFailed { payment_id: PaymentId([42; 32]), payment_hash: PaymentHash([42; 32]), - path: path.clone(), + path, short_channel_id: Some(scored_scid), }); let event = receiver