Skip to content

Commit

Permalink
Merge rust-bitcoin#3122: Introduce helper function name policy
Browse files Browse the repository at this point in the history
84df343 Fix markdown list items (Tobin C. Harding)
0a45c68 Introduce helper function name policy (Tobin C. Harding)

Pull request description:

  As much as it hurts the C hacker inside me we have settled on using `_internal` to mark private function names that clash with a public function of the same name.

  Introduce a policy section and rename one instance, I did not grep the codebase looking for other violations.

  This came up because I had to look at what `_inner` implied when reading the function name somewhere else.

ACKs for top commit:
  storopoli:
    ACK 84df343
  apoelstra:
    ACK 84df343 successfully ran local tests; sgtm. should probably update rust-miniscript which uses a `real_` prefix

Tree-SHA512: aece73fac54c4f34bdba72c08721586eb6d76dc9191442bbca43301f2af3d3b3e3217383f1ad20752fa7654e7f5d09927d1a4b72602aa064e76d550b5d6e81bd
  • Loading branch information
apoelstra committed Aug 5, 2024
2 parents 865fdf7 + 84df343 commit 5cca2f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ Library reflects Bitcoin Core approach whenever possible.

Naming of data structures/enums and their fields/variants must follow names used
in Bitcoin Core, with the following exceptions:
- the case should follow Rust standards (i.e. PascalCase for types and
snake_case for fields and variants);
- omit `C`-prefixes.
- The case should follow Rust standards (i.e. PascalCase for types and snake_case for fields and variants).
- Omit `C`-prefixes.
- If function `foo` needs a private helper function, use `foo_internal`.

### Upgrading dependencies

Expand Down
6 changes: 3 additions & 3 deletions bitcoin/src/blockdata/script/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl Script {
///
/// [`minimal_non_dust_custom`]: Script::minimal_non_dust_custom
pub fn minimal_non_dust(&self) -> crate::Amount {
self.minimal_non_dust_inner(DUST_RELAY_TX_FEE.into())
self.minimal_non_dust_internal(DUST_RELAY_TX_FEE.into())
}

/// Returns the minimum value an output with this script should have in order to be
Expand All @@ -387,10 +387,10 @@ impl Script {
///
/// [`minimal_non_dust`]: Script::minimal_non_dust
pub fn minimal_non_dust_custom(&self, dust_relay_fee: FeeRate) -> crate::Amount {
self.minimal_non_dust_inner(dust_relay_fee.to_sat_per_kwu() * 4)
self.minimal_non_dust_internal(dust_relay_fee.to_sat_per_kwu() * 4)
}

fn minimal_non_dust_inner(&self, dust_relay_fee: u64) -> crate::Amount {
fn minimal_non_dust_internal(&self, dust_relay_fee: u64) -> crate::Amount {
// This must never be lower than Bitcoin Core's GetDustThreshold() (as of v0.21) as it may
// otherwise allow users to create transactions which likely can never be broadcast/confirmed.
let sats = dust_relay_fee
Expand Down

0 comments on commit 5cca2f2

Please sign in to comment.