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

Allow BdkElectrumClient to take client by reference #1825

Conversation

evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Feb 6, 2025

Description

Previously, BdkElectrumClient has to take ownership of the internal electrum client.

This is an alternative of #1820. #1820 removes the ability to have BdkElectrumClient take ownership.

Notes to the reviewers

Is the C generic necessary? It's there just in case a caller would like to use something other than electrum_client::Client. Is anyone using the RawClients directly?

If all we want to for BdkElectrumClient to take in &electrum_client::Client we can just do the following in the electrum_client crate.

impl<E: ElectrumApi> ElectrumApi for &E { /* todo */ }

Changelog notice

  • Allow BdkElectrumClient to take in the internal client as reference or smart pointer.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Previously, `BdkElectrumClient` has to take ownership of the internal
electrum client.

This is an alternative of bitcoindevkit#1820. bitcoindevkit#1820 removes the ability to have
`BdkElectrumClient` take ownership.
@@ -6,7 +6,9 @@ use bdk_core::{
};
use electrum_client::{ElectrumApi, Error, HeaderNotification};
use std::{
borrow::Borrow,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify why Borrow would be preferable to Deref in this case, especially since it requires a bunch of additional boilerplate, etc?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because Borrow has a blanket implementation so that any T impls Borrow<T>.

We still want to keep the ability to take a client by ownership imo.

@evanlinjin
Copy link
Member Author

Closing, as bitcoindevkit/rust-electrum-client#163 is a superior solution.

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.

2 participants