From: Matt Corallo Date: Thu, 22 Aug 2019 21:41:55 +0000 (-0400) Subject: Split DNS results writing and data store writing X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a264197c4fa7babe2ce2865f1b12e4db07ae687e;p=dnsseed-rust Split DNS results writing and data store writing --- diff --git a/src/datastore.rs b/src/datastore.rs index 05d8a1e..30d2c8e 100644 --- a/src/datastore.rs +++ b/src/datastore.rs @@ -434,8 +434,12 @@ impl Store { tokio::fs::rename(nodes_file.clone() + ".tmp", nodes_file) }); + settings_future.join(nodes_future).then(|_| { future::ok(()) }) + } + + pub fn write_dns(&'static self) -> impl Future { let dns_file = self.store.clone() + "/nodes.dump"; - let dns_future = File::create(dns_file.clone() + ".tmp").and_then(move |f| { + File::create(dns_file.clone() + ".tmp").and_then(move |f| { let mut dns_buff = String::new(); { let mut rng = thread_rng(); @@ -505,9 +509,7 @@ impl Store { f.poll_sync_all() }).and_then(|_| { tokio::fs::rename(dns_file.clone() + ".tmp", dns_file) - }); - - settings_future.join3(nodes_future, dns_future).then(|_| { future::ok(()) }) + }).then(|_| { future::ok(()) }) } pub fn get_next_scan_nodes(&self) -> Vec { diff --git a/src/main.rs b/src/main.rs index 4bf9351..f72ba34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -258,7 +258,8 @@ fn poll_dnsseeds() { printer.add_line(format!("Added {} new addresses from other DNS seeds", new_addrs), false); Delay::new(Instant::now() + Duration::from_secs(60)).then(|_| { let store = unsafe { DATA_STORE.as_ref().unwrap() }; - store.save_data().then(|_| { + let dns_future = store.write_dns(); + store.save_data().join(dns_future).then(|_| { if !START_SHUTDOWN.load(Ordering::Relaxed) { poll_dnsseeds(); }