]> git.bitcoin.ninja Git - dnsseed-rust/commitdiff
Split DNS results writing and data store writing
authorMatt Corallo <git@bluematt.me>
Thu, 22 Aug 2019 21:41:55 +0000 (17:41 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 22 Aug 2019 21:41:55 +0000 (17:41 -0400)
src/datastore.rs
src/main.rs

index 05d8a1e9ba0ef54fc0fa539899afda08ddf40a4e..30d2c8e8b21431cf917c0ec6d1436c7016f3a07c 100644 (file)
@@ -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<Item=(), Error=()> {
                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<SocketAddr> {
index 4bf93510c5e3aaa41ba8fb38e8c4356965f3af73..f72ba343a1972cbc1ddb03e06e2584ee7e25ded1 100644 (file)
@@ -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();
                                }