From: nickfarrow Date: Tue, 5 Apr 2022 02:11:52 +0000 (+1000) Subject: Create vector of thread handles to spawn threads X-Git-Tag: v0.18.0~8^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/struct.ScriptLeaf.html?a=commitdiff_plain;h=adef166b22d5c95006df39fd8c57574624071189;p=bdk Create vector of thread handles to spawn threads Signed-off-by: nickfarrow --- diff --git a/src/blockchain/esplora/ureq.rs b/src/blockchain/esplora/ureq.rs index 9bfa378f..55f1cf76 100644 --- a/src/blockchain/esplora/ureq.rs +++ b/src/blockchain/esplora/ureq.rs @@ -127,10 +127,11 @@ impl WalletSync for EsploraBlockchain { .take(self.concurrency as usize) .cloned(); - let handles = scripts.map(move |script| { + let mut handles = vec![]; + for script in scripts { let client = self.url_client.clone(); // make each request in its own thread. - std::thread::spawn(move || { + handles.push(std::thread::spawn(move || { let mut related_txs: Vec = client._scripthash_txs(&script, None)?; let n_confirmed = @@ -152,10 +153,11 @@ impl WalletSync for EsploraBlockchain { } } Result::<_, Error>::Ok(related_txs) - }) - }); + })); + } let txs_per_script: Vec> = handles + .into_iter() .map(|handle| handle.join().unwrap()) .collect::>()?; let mut satisfaction = vec![];