Merge rust-bitcoin/rust-bitcoin#3122: Introduce helper function name policy

84df3438ca Fix markdown list items (Tobin C. Harding)
0a45c68cf8 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 84df3438ca
  apoelstra:
    ACK 84df3438ca successfully ran local tests; sgtm. should probably update rust-miniscript which uses a `real_` prefix

Tree-SHA512: aece73fac54c4f34bdba72c08721586eb6d76dc9191442bbca43301f2af3d3b3e3217383f1ad20752fa7654e7f5d09927d1a4b72602aa064e76d550b5d6e81bd
This commit is contained in:
merge-script 2024-08-05 23:11:05 +00:00
commit 5cca2f271d
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
2 changed files with 6 additions and 6 deletions

View File

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

View File

@ -372,7 +372,7 @@ impl Script {
/// ///
/// [`minimal_non_dust_custom`]: Script::minimal_non_dust_custom /// [`minimal_non_dust_custom`]: Script::minimal_non_dust_custom
pub fn minimal_non_dust(&self) -> crate::Amount { 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 /// Returns the minimum value an output with this script should have in order to be
@ -387,10 +387,10 @@ impl Script {
/// ///
/// [`minimal_non_dust`]: Script::minimal_non_dust /// [`minimal_non_dust`]: Script::minimal_non_dust
pub fn minimal_non_dust_custom(&self, dust_relay_fee: FeeRate) -> crate::Amount { 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 // 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. // otherwise allow users to create transactions which likely can never be broadcast/confirmed.
let sats = dust_relay_fee let sats = dust_relay_fee