From: Matt Corallo Date: Mon, 9 Sep 2024 13:42:54 +0000 (+0000) Subject: Rename `AtomicCounter::get_increment` to simply `next` X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=1c2bd097a8c2d12893cfa99a5359345a86b7dc5f;p=rust-lightning Rename `AtomicCounter::get_increment` to simply `next` Its a counter, `next` is super clear, `get_increment` is a bit less so. --- diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs index deec638f7..15e911cbb 100644 --- a/lightning/src/ln/interactivetxs.rs +++ b/lightning/src/ln/interactivetxs.rs @@ -1328,7 +1328,7 @@ mod tests { impl EntropySource for TestEntropySource { fn get_secure_random_bytes(&self) -> [u8; 32] { let mut res = [0u8; 32]; - let increment = self.0.get_increment(); + let increment = self.0.next(); for (i, byte) in res.iter_mut().enumerate() { // Rotate the increment value by 'i' bits to the right, to avoid clashes // when `generate_local_serial_id` does a parity flip on consecutive calls for the diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 51695bba0..ca6d70941 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1053,7 +1053,7 @@ impl SecretKey { let mut ephemeral_hash = self.ephemeral_key_midstate.clone(); - let counter = self.peer_counter.get_increment(); + let counter = self.peer_counter.next(); ephemeral_hash.input(&counter.to_le_bytes()); SecretKey::from_slice(&Sha256::from_engine(ephemeral_hash).to_byte_array()).expect("You broke SHA-256!") } diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index 1a84caf36..4b8a9e025 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -2504,7 +2504,7 @@ impl RandomBytes { impl EntropySource for RandomBytes { fn get_secure_random_bytes(&self) -> [u8; 32] { - let index = self.index.get_increment(); + let index = self.index.next(); let mut nonce = [0u8; 16]; nonce[..8].copy_from_slice(&index.to_be_bytes()); ChaCha20::get_single_block(&self.seed, &nonce) diff --git a/lightning/src/util/atomic_counter.rs b/lightning/src/util/atomic_counter.rs index bb2dbc0f7..050bcadf8 100644 --- a/lightning/src/util/atomic_counter.rs +++ b/lightning/src/util/atomic_counter.rs @@ -21,7 +21,7 @@ impl AtomicCounter { counter: Mutex::new(0), } } - pub(crate) fn get_increment(&self) -> u64 { + pub(crate) fn next(&self) -> u64 { #[cfg(target_has_atomic = "64")] { self.counter.fetch_add(1, Ordering::AcqRel) }