rust-bitcoin / rust-bitcoin/rust-bitcoin
Global `Network`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.7k
- Forks
- 1k
- Avg merge
- 4d 39m
- Merged PRs (30d)
- 86
Description
I just realized that many applications allow the user to configure them for a single network which is then used in the whole program. One would normally parse the network from configuration and then pass it around in arguments. This can be a bit annoying.
Maybe we could also provide a global (internally AtomicU8) that user could set in main and then use alternative functions that don't require Network. The functions would obviously need to panic if the network is not set. To avoid accidental use by libraries (and also target_has_atomic issues) this should be behind a feature flag. When the flag is activated we could also provide an implementation of FromStr/Deserialize for Address<NetworkChecked>. (NetworkUnchecked should keep its behavior regardless of the flag.)
Note that this is intended for applications only, libraries should continue to support arguments. Also our library should support both interfaces.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing Network and Address/NetworkUnchecked APIs and how applications currently pass Network values. Review the feature-flag and target_has_atomic constraints described in the issue before proposing the global setter and alternative functions. Done means both interfaces remain supported, unset global access panics, NetworkUnchecked is unchanged, and the requested parsing conversions work only under the flag.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100