Skip to content

Commit

Permalink
Have sync_wallets use a multi-threaded runtime
Browse files Browse the repository at this point in the history
As part of the `OuputSweeper` we broadcast in the `Confirm`
implementation, which would be called during transaction syncing.
Since our broadcasting happens async but via the intermediate blocking
`BroadcasterInterface` we have to transition from `sync_wallets`
(blocking) -> LDK/BDK wallet sync (async) -> Confirm (blocking) ->
BroadcasterInterface (blocking) -> bdk::Wallet::broadcast (async).

However, as the `block_in_place`/`block_on` combo is only usable for
multi-threaded runtimes, this new codepath now requires the use of a
multi-threaded runtime in `sync_wallets` (note this is the case even
though we use a stored, *different* multi-threaded runtime for the
actual broadcasting. **sigh**).
  • Loading branch information
tnull committed Aug 15, 2023
1 parent 4e2bba5 commit 19e55d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
];

tokio::task::block_in_place(move || {
tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(
async move {
let now = Instant::now();
match wallet.sync().await {
Expand Down

0 comments on commit 19e55d9

Please sign in to comment.