Skip to content
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

Make everything async #26

Closed
wants to merge 22 commits into from

Conversation

tnull
Copy link
Collaborator

@tnull tnull commented Oct 20, 2022

Based on #9, #10, #11.

We migrate BDK and other remaining blocking parts to async.

}
}

pub(crate) fn set_runtime(&self, tokio_runtime: Arc<tokio::runtime::Runtime>) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now have taken the approach of setting and dropping the runtime on start()/stop(). However, a probably cleaner alternative approach would be to use tokio::Runtime::enter upon setup and just storing the EnterGuard somewhere. However, this may result in panicking if we'd end up calling tokio::spawn out-of-context. As I'm currently not 100% sure that this could never happen, I now went with this uglier approach for the time being, but will look into it again.

src/access.rs Outdated
return fallback_fee;
}

locked_runtime.as_ref().unwrap().block_on(async {
Copy link
Collaborator Author

@tnull tnull Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As block_on seems to have quite a few drawbacks even in the multithreaded runtime case I'll switch all of these to using spawn+mspc channels.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of most of them, one non-trivial left for the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be blocked on bitcoindevkit/bdk#795, otherwise we need to run all wallet operations in it's own thread and keep it block_on.

@tnull tnull force-pushed the 2022-10-make-everything-async branch from bac34b5 to ed49984 Compare October 21, 2022 11:50
We migrate BDK and other remaining blocking parts to async.
@tnull
Copy link
Collaborator Author

tnull commented Nov 30, 2022

Closing as it became a requirement to already include this in #11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant