Introduce helper function name policy

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.
This commit is contained in:
Tobin C. Harding 2024-08-05 08:10:29 +10:00
parent 8c0de95749
commit 0a45c68cf8
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 4 additions and 3 deletions

View File

@ -175,6 +175,7 @@ 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.
- if function `foo` needs a private helper function, use `foo_internal`.
### Upgrading dependencies

View File

@ -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
@ -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