Skip to content

Uses node's runtime in sync_wallets() #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,39 +1253,38 @@ impl Node {
if rt_lock.is_none() {
return Err(Error::NotRunning);
}
let runtime = rt_lock.as_ref().unwrap();

let chain_source = Arc::clone(&self.chain_source);
let sync_cman = Arc::clone(&self.channel_manager);
let sync_cmon = Arc::clone(&self.chain_monitor);
let sync_sweeper = Arc::clone(&self.output_sweeper);
tokio::task::block_in_place(move || {
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(
async move {
match chain_source.as_ref() {
ChainSource::Esplora { .. } => {
chain_source.update_fee_rate_estimates().await?;
chain_source
.sync_lightning_wallet(sync_cman, sync_cmon, sync_sweeper)
.await?;
chain_source.sync_onchain_wallet().await?;
},
ChainSource::Electrum { .. } => {
chain_source.update_fee_rate_estimates().await?;
chain_source
.sync_lightning_wallet(sync_cman, sync_cmon, sync_sweeper)
.await?;
chain_source.sync_onchain_wallet().await?;
},
ChainSource::BitcoindRpc { .. } => {
chain_source.update_fee_rate_estimates().await?;
chain_source
.poll_and_update_listeners(sync_cman, sync_cmon, sync_sweeper)
.await?;
},
}
Ok(())
},
)
runtime.block_on(async move {
match chain_source.as_ref() {
ChainSource::Esplora { .. } => {
chain_source.update_fee_rate_estimates().await?;
chain_source
.sync_lightning_wallet(sync_cman, sync_cmon, sync_sweeper)
.await?;
chain_source.sync_onchain_wallet().await?;
},
ChainSource::Electrum { .. } => {
chain_source.update_fee_rate_estimates().await?;
chain_source
.sync_lightning_wallet(sync_cman, sync_cmon, sync_sweeper)
.await?;
chain_source.sync_onchain_wallet().await?;
},
ChainSource::BitcoindRpc { .. } => {
chain_source.update_fee_rate_estimates().await?;
chain_source
.poll_and_update_listeners(sync_cman, sync_cmon, sync_sweeper)
.await?;
},
}
Ok(())
})
})
}

Expand Down
Loading