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

rename scan to scan_with_keychain #1117

Closed
wants to merge 6 commits into from

Conversation

448-OG
Copy link

@448-OG 448-OG commented Sep 11, 2023

The purpose of this PR is to make changes regarding issue #1112

Notes to the reviewers

This is a draft pull request

Checklists

All Submissions:

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

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing (I run the tests using cargo test --all-features
  • I'm linking the issue being fixed by this PR

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

Left a few comments. Tests are failing, check the CI logs :)

crates/electrum/src/electrum_ext.rs Show resolved Hide resolved
crates/electrum/src/electrum_ext.rs Show resolved Hide resolved
crates/electrum/src/electrum_ext.rs Outdated Show resolved Hide resolved
crates/electrum/src/electrum_ext.rs Outdated Show resolved Hide resolved
@448-OG
Copy link
Author

448-OG commented Sep 14, 2023

I have made some changes, a review is most welcome.

@danielabrozzoni
Copy link
Member

You have a few conflicts, rebase on master to fix them

@448-OG
Copy link
Author

448-OG commented Sep 15, 2023

You have a few conflicts, rebase on master to fix them

Sorry about that. I have fixed the conflicts

…trumExt` no longer takes `txids` and `outpoints` as arguments

Fix: `example_electrum` and `wallet_electrum` in `example-crates` no longer take values for these arguments that implement the `scan` method of trait `ElectrumExt`
…ethod `scan` to `scan_with_keychain`

BREAKING CHANGE: In `electrum` crate rename the `ElectrumExt` trait method `scan_without_keychain` to `sync`

Fix: Modify the `example_electrum` and `wallet_electrum` examples to use new methods from `ElectrumExt` trait
Chore: Implement recommendations from cargo clippy
…ethod `scan` to `scan_with_keychain`

BREAKING CHANGE: In `electrum` crate rename the `ElectrumExt` trait method `scan_without_keychain` to `sync`

Fix: Modify the `example_electrum` and `wallet_electrum` examples to use new methods from `ElectrumExt` trait

This commit has been rebased to use commits at hash `c20a4da9fc902a062eb217b39e37a32d9e64a148`

The requested updates have been applied using this commits and previous commits are mostly outdated
@@ -836,7 +836,7 @@ mod test {
let drain_script = ScriptBuf::default();
let target_amount = 250_000 + FEE_AMOUNT;

let result = LargestFirstCoinSelection::default()
let result = LargestFirstCoinSelection
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these changes on coin selection slipped in because of the rebase. You have to remove them. There is more other files. Just cross check

Copy link
Author

Choose a reason for hiding this comment

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

These changes were as a result of running clippy. If you run clippy on master you will get recommendations to remove them. Since in rust tuple struct LargestFirstCoinSelection you dont need to call ::default() to initialize it

Copy link
Member

Choose a reason for hiding this comment

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

Generally it's better to handle fixing clippy changes in a separate commit or PR to make the review easier. Also a nit on commit messages, instead of BREAKING CHANGE: I'd use the notation refactor!(<module name>): .... See: https://www.conventionalcommits.org/en/v1.0.0/

And as @LLFourn mentioned we may end up incorporating this rename into another PR but if you have time it wouldn't hurt to fix this one up in case we can use it.

txids: impl IntoIterator<Item = Txid>,
outpoints: impl IntoIterator<Item = OutPoint>,
_txids: impl IntoIterator<Item = Txid>,
_outpoints: impl IntoIterator<Item = OutPoint>,
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't we completely remove _txids and _outpoints? I don't see their utility

Copy link
Author

Choose a reason for hiding this comment

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

They are used in bdk/example-crates/example_electrum/src/main.rs line 249, do I remove the code in examples too to reflect this?

Copy link
Contributor

Choose a reason for hiding this comment

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

txids and outpoints is meant to return you any relevant transactions to these items. They can't just be _ignored. A more significant refactoring is needed so that this method does not call scan_with_keychain but implements its own scanning logic.

crates/electrum/src/electrum_ext.rs Outdated Show resolved Hide resolved
&self,
prev_tip: Option<CheckPoint>,
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
txids: impl IntoIterator<Item = Txid>,
outpoints: impl IntoIterator<Item = OutPoint>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we are removing txids and outpoints it doesn't make sense to be calling populate_with_txids and populate_with_outpoints here. Should separate methods be created to get these updates? @LLFourn @evanlinjin

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes the separate method is scan. scan is still meant to be doing this.

@448-OG
Copy link
Author

448-OG commented Sep 15, 2023

I will fix doc issues ASAP

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

Make sure that all your commits are clean, and that don't introduce changes that you later undo in newer commits. For example, 2fa5fc6 introduces a couple of unwanted "<<<<<<< HEAD" that you later remove in 2a9a2e0 - instead, squash the two commits together.

Regarding commit messages:

BREAKING CHANGE: In electrum crate the method scan of trait `Elec…
…trumExt` no longer takes `txids` and `outpoints` as arguments

to:

refactor(electrum)!: `ElectrumExt::scan` no longer takes `txids`, `outpoints`

Notice that the part before : is in lowercase characters, and the part after : is capitalized.
9655e31's now looks like this:

Chore: Run cargo fmt

instead, it should be:

chore: Run cargo clippy

Since you're running clippy and not fmt :) Also, if the commit title is explanatory enough, you don't have to write a commit message.

If you've never rewritten commit messages, this can be of help: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

crates/electrum/src/electrum_ext.rs Outdated Show resolved Hide resolved
…scan_with_keychain`

    This solves the issue where CI tests for docs.rs error on rustdoc warning `--cfg docsrs -Dwarnings`
@448-OG
Copy link
Author

448-OG commented Sep 15, 2023

Make sure that all your commits are clean, and that don't introduce changes that you later undo in newer commits. For example, 2fa5fc6 introduces a couple of unwanted "<<<<<<< HEAD" that you later remove in 2a9a2e0 - instead, squash the two commits together.

Regarding commit messages:

* We use conventional commits (https://www.conventionalcommits.org/en/v1.0.0/), which use the `!` in the commit title to signal breaking changes (https://www.conventionalcommits.org/en/v1.0.0/#commit-message-with--to-draw-attention-to-breaking-change). Also, we don't put "In ... crate", we simply put "_name of the crate_:" at the start of the title. As an example, [7e91849](https://github.com/bitcoindevkit/bdk/commit/7e91849f7c1896d2bdc4affc329eb50b3411828c)'s title should go from:
BREAKING CHANGE: In electrum crate the method scan of trait `Elec…
…trumExt` no longer takes `txids` and `outpoints` as arguments

to:

refactor(electrum)!: `ElectrumExt::scan` no longer takes `txids`, `outpoints`

Notice that the part before : is in lowercase characters, and the part after : is capitalized. 9655e31's now looks like this:

Chore: Run cargo fmt

instead, it should be:

chore: Run cargo clippy

Since you're running clippy and not fmt :) Also, if the commit title is explanatory enough, you don't have to write a commit message.

If you've never rewritten commit messages, this can be of help: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

Thanks. I will look into commit messages

@448-OG 448-OG marked this pull request as ready for review September 18, 2023 08:27
@nondiremanuel nondiremanuel added this to the 1.0.0-alpha.3 milestone Sep 26, 2023
@danielabrozzoni
Copy link
Member

Hey @448-OG, are you still working on this? Do you need help with anything?

@448-OG
Copy link
Author

448-OG commented Oct 5, 2023

Hey @448-OG, are you still working on this? Do you need help with anything?

Hey @danielabrozzoni I had finished doing changes, there were some comments @vladimirfomene made that I commented on. Unless there are new changes requested, my PR is ready for review

@nondiremanuel
Copy link

After today's discussion in the Lib Team Call, a check on whether all the comments were addressed is needed on this PR. Also it will probably need to be rebased after the ci fix of #1182

@LLFourn
Copy link
Contributor

LLFourn commented Nov 10, 2023

My opinion is that we probably want to close this PR in favor of one that solves all the problems in #1195 at once.

@nondiremanuel nondiremanuel modified the milestones: 1.0.0-alpha.3, 1.0.0-alpha.4 Nov 20, 2023
@nondiremanuel nondiremanuel modified the milestones: 1.0.0-alpha.4, 1.0.0 Jan 6, 2024
@notmandatory notmandatory added the api A breaking API change label Jan 16, 2024
@notmandatory
Copy link
Member

notmandatory commented Jan 16, 2024

@448-OG thanks for your work on this but the issue got fixed with #1235.

@notmandatory notmandatory removed this from the 1.0.0 milestone Jan 16, 2024
@448-OG
Copy link
Author

448-OG commented Feb 27, 2024

Thanks for the opportunity and reviews I got, I learnt quite a few things about the library.

@448-OG 448-OG deleted the sync_with_keychain branch February 27, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api A breaking API change
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants