Skip to content

Commit 5fbed07

Browse files
committed
Run rpc source in a blocking context
1 parent c176c0e commit 5fbed07

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

client/src/sync.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl Spaced {
267267
_ => panic!("unsupported network"),
268268
};
269269

270-
let source = BitcoinBlockSource::new(rpc.clone());
270+
271271

272272
// Wait for the RPC node to be ready
273273
let mut attempts = 0;
@@ -282,8 +282,13 @@ impl Spaced {
282282
last_error
283283
));
284284
}
285-
let best_chain =
286-
source.get_best_chain(Some(anchor.height), network.fallback_network());
285+
286+
let rpc_task = rpc.clone();
287+
let net_task = network.fallback_network();
288+
let best_chain = tokio::task::spawn_blocking(move || {
289+
let source = BitcoinBlockSource::new(rpc_task);
290+
source.get_best_chain(Some(anchor.height), net_task)
291+
}).await.expect("join");
287292

288293
match best_chain {
289294
Ok(Some(tip)) => {

0 commit comments

Comments
 (0)