Skip to content

Commit adef166

Browse files
committed
Create vector of thread handles to spawn threads
Signed-off-by: nickfarrow <[email protected]>
1 parent 9c0141b commit adef166

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/blockchain/esplora/ureq.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ impl WalletSync for EsploraBlockchain {
127127
.take(self.concurrency as usize)
128128
.cloned();
129129

130-
let handles = scripts.map(move |script| {
130+
let mut handles = vec![];
131+
for script in scripts {
131132
let client = self.url_client.clone();
132133
// make each request in its own thread.
133-
std::thread::spawn(move || {
134+
handles.push(std::thread::spawn(move || {
134135
let mut related_txs: Vec<Tx> = client._scripthash_txs(&script, None)?;
135136

136137
let n_confirmed =
@@ -152,10 +153,11 @@ impl WalletSync for EsploraBlockchain {
152153
}
153154
}
154155
Result::<_, Error>::Ok(related_txs)
155-
})
156-
});
156+
}));
157+
}
157158

158159
let txs_per_script: Vec<Vec<Tx>> = handles
160+
.into_iter()
159161
.map(|handle| handle.join().unwrap())
160162
.collect::<Result<_, _>>()?;
161163
let mut satisfaction = vec![];

0 commit comments

Comments
 (0)