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

Increase terseness in descriptor module #376

Merged
merged 4 commits into from
Apr 30, 2022

Conversation

tcharding
Copy link
Member

In an effort to better understand the descriptor module and its associated types; do some refactoring and re-naming of types making the key struct identifiers more terse.

  • Patch 1: refactor, code layout
  • Patch 2: docs improvements
  • Patch 3: Minor refactor
  • Patch 4: Use more terse names, this is the bulk of the PR

If this is too invasive for someone only recently making their way around the crate, feel free to say so :)

Source files are easier to read if the most important stuff comes first.

We have a bunch of key structs, order them pub/priv and in order of
importance i.e., declare things below where they are first used.

Refactor only, no logic changes.
Improve the documentation on the various key structs.
The `KeySource` type is a type alias from `bitcoin::bip32` for a
tuple (fingerprint, derivation_path). In other places in the code we use
the full tuple, we should be uniform and use one or the other. Elect to
use the tuple.

Use full tuple `(FingerPrint, DerivationPath)` instead of `KeySource`.
We have a plethora of key structs in the `key` module. Attempt to use
more terse names without loosing any clarity.

In particular:

1. Variants

- Replace SinglePub with Single
- Replace SinglePriv with Single

The variants `SinglePub`, and `SinglePriv` stutter, we know what keys
they are so can use `Single` with no loss of clarity.

2. Remove `Descriptor` from the nested descriptor types, users can use
`descriptor::singlePub` if needed.
Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK 5a8514a. These changes are increase the code quality.

@sanket1729 sanket1729 merged commit 709d641 into rust-bitcoin:master Apr 30, 2022
@tcharding tcharding deleted the more-terse branch May 1, 2022 23:49
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.

None yet

2 participants