Create vector of thread handles to spawn threads
Signed-off-by: nickfarrow <nick@nickfarrow.com>
This commit is contained in:
parent
9c0141b5e3
commit
adef166b22
@ -127,10 +127,11 @@ impl WalletSync for EsploraBlockchain {
|
|||||||
.take(self.concurrency as usize)
|
.take(self.concurrency as usize)
|
||||||
.cloned();
|
.cloned();
|
||||||
|
|
||||||
let handles = scripts.map(move |script| {
|
let mut handles = vec![];
|
||||||
|
for script in scripts {
|
||||||
let client = self.url_client.clone();
|
let client = self.url_client.clone();
|
||||||
// make each request in its own thread.
|
// make each request in its own thread.
|
||||||
std::thread::spawn(move || {
|
handles.push(std::thread::spawn(move || {
|
||||||
let mut related_txs: Vec<Tx> = client._scripthash_txs(&script, None)?;
|
let mut related_txs: Vec<Tx> = client._scripthash_txs(&script, None)?;
|
||||||
|
|
||||||
let n_confirmed =
|
let n_confirmed =
|
||||||
@ -152,10 +153,11 @@ impl WalletSync for EsploraBlockchain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Result::<_, Error>::Ok(related_txs)
|
Result::<_, Error>::Ok(related_txs)
|
||||||
})
|
}));
|
||||||
});
|
}
|
||||||
|
|
||||||
let txs_per_script: Vec<Vec<Tx>> = handles
|
let txs_per_script: Vec<Vec<Tx>> = handles
|
||||||
|
.into_iter()
|
||||||
.map(|handle| handle.join().unwrap())
|
.map(|handle| handle.join().unwrap())
|
||||||
.collect::<Result<_, _>>()?;
|
.collect::<Result<_, _>>()?;
|
||||||
let mut satisfaction = vec![];
|
let mut satisfaction = vec![];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user