rust-bitcoin / rust-bitcoin/rust-miniscript

`checksum` module needs some love

Open
#610 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
426
Forks
200
Avg merge
7d 17h
Merged PRs (30d)
8

Description

After working on https://github.com/rust-bitcoin/rust-miniscript/pull/608 I noticed a few things:

  • We seem to be using fmt::Write::write_str with the implied suggestion that we avoid allocation of a string but I think that fmt::Argumenst::as_str() gets called and only avoids allocation for static strings (no uses of placeholders {}), since we always use {} I'm reasonably confident that this is allocating.
  • There are some optimisation possibilities by using iterator adapters instead of strings, ie take an iterarator of chars and yield the chars + # + the checksum.
  • The public API is a bit messy:
    • checksum::Formatter should not be public because it is not really a general purpose formatter, it is specifically for writing a descriptor to a formatter and overriding the use of alternate to control the addition of the checksum.
    • descriptor::checksum::desc_checksum could be better named as could descriptor::checksum::verify_checksum to use Rust naming convention (ie., users should be using a single path on functions so checksum::verify seems better, not sure about the other one.
  • Error handling could be improved if/when we start to do errors elsewhere

Related:

  • #323
  • #554

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the checksum module and the discussion in related issues #323 and #554. The issue lists allocation, iterator, public API, naming, and error-handling concerns but does not identify files, tests, or an agreed subset of work. Confirm scope and completion criteria with maintainers before making changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.