]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename `AtomicCounter::get_increment` to simply `next` 2024-09-atomic-cleanups
authorMatt Corallo <git@bluematt.me>
Mon, 9 Sep 2024 13:42:54 +0000 (13:42 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 12 Sep 2024 14:32:43 +0000 (14:32 +0000)
Its a counter, `next` is super clear, `get_increment` is a bit
less so.

lightning/src/ln/interactivetxs.rs
lightning/src/ln/peer_handler.rs
lightning/src/sign/mod.rs
lightning/src/util/atomic_counter.rs

index deec638f7f1a01e1e63d9ebbfd0d1e4c11d103a7..15e911cbb4c8663e2e686ca5b41cdb56420633a6 100644 (file)
@@ -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
index 51695bba09afc01e62afac9c69c259eba591677c..ca6d709410f9ca48582c66f70a97d5a8cfff6a76 100644 (file)
@@ -1053,7 +1053,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
 
        fn get_ephemeral_key(&self) -> 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!")
        }
index 1a84caf36394ae0954b76495f0faddf06e46ffba..4b8a9e0255a4195fec6bef58c9218167628a3aed 100644 (file)
@@ -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)
index bb2dbc0f737c51ae5a6c09054dc129316f38a33d..050bcadf807894334a315a3968fe0fa46d27b56a 100644 (file)
@@ -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)
                }