From 0a45c68cf8625b211109e2dbb528c73b9fa00caf Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 5 Aug 2024 08:10:29 +1000 Subject: [PATCH 1/2] 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. --- CONTRIBUTING.md | 1 + bitcoin/src/blockdata/script/borrowed.rs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 903ed53d3e..b919d456ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/bitcoin/src/blockdata/script/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs index 9ecd04497c..19cc614f54 100644 --- a/bitcoin/src/blockdata/script/borrowed.rs +++ b/bitcoin/src/blockdata/script/borrowed.rs @@ -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 From 84df3438caa58263a9cbc8a41eace9c1f0fdca6b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 6 Aug 2024 04:18:23 +1000 Subject: [PATCH 2/2] Fix markdown list items Fix list items to use capital letters because the list items are sentences (have trailing full stop already). Also, use a long single line because it is [subjectively] easier to read the list. --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b919d456ce..43c38cb2a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -172,10 +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. -- if function `foo` needs a private helper function, use `foo_internal`. +- 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