Skip to content

Commit f8692b8

Browse files
committed
Add previously ommitted block_in_place
While it's not strictly necessary for us internally, it's nice to add to allow the Node itself to be used in tokio context.
1 parent 821b06a commit f8692b8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/lib.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -309,22 +309,25 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
309309
// Block to ensure we update our fee rate cache once on startup
310310
let wallet = Arc::clone(&self.wallet);
311311
let sync_logger = Arc::clone(&self.logger);
312-
runtime.block_on(async move {
313-
let now = Instant::now();
314-
match wallet.update_fee_estimates().await {
315-
Ok(()) => {
316-
log_info!(
317-
sync_logger,
318-
"Initial fee rate cache update finished in {}ms.",
319-
now.elapsed().as_millis()
320-
);
321-
Ok(())
322-
}
323-
Err(e) => {
324-
log_error!(sync_logger, "Initial fee rate cache update failed: {}", e,);
325-
Err(e)
312+
let runtime_ref = &runtime;
313+
tokio::task::block_in_place(move || {
314+
runtime_ref.block_on(async move {
315+
let now = Instant::now();
316+
match wallet.update_fee_estimates().await {
317+
Ok(()) => {
318+
log_info!(
319+
sync_logger,
320+
"Initial fee rate cache update finished in {}ms.",
321+
now.elapsed().as_millis()
322+
);
323+
Ok(())
324+
}
325+
Err(e) => {
326+
log_error!(sync_logger, "Initial fee rate cache update failed: {}", e,);
327+
Err(e)
328+
}
326329
}
327-
}
330+
})
328331
})?;
329332

330333
// Setup wallet sync

0 commit comments

Comments
 (0)