From 1fe974265c6749b29535fbf91e66b355afde65e6 Mon Sep 17 00:00:00 2001 From: Federico Franzoni <8609060+fed-franz@users.noreply.github.com> Date: Tue, 20 Aug 2024 18:17:09 +0200 Subject: [PATCH] node-data: fix some comments --- node-data/src/bls.rs | 12 ++++-------- node-data/src/encoding.rs | 4 ++-- node-data/src/ledger/attestation.rs | 4 ++-- node-data/src/ledger/block.rs | 2 +- node-data/src/message.rs | 10 +++------- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/node-data/src/bls.rs b/node-data/src/bls.rs index ec80663f94..2be1a30a47 100644 --- a/node-data/src/bls.rs +++ b/node-data/src/bls.rs @@ -61,8 +61,8 @@ impl PublicKey { } /// `bytes` returns a reference to the pk.to_bytes() initialized on - /// PublicKey::new call. NB Frequent use of `to_bytes()` creates a - /// noticeable perf overhead. + /// PublicKey::new call. NB: Frequent use of `to_bytes()` creates a + /// noticeable performance overhead. pub fn bytes(&self) -> &PublicKeyBytes { &self.as_bytes } @@ -104,7 +104,7 @@ impl std::fmt::Debug for PublicKey { f.debug_struct("PublicKey").field("bs58", &bs).finish() } } -/// a wrapper of 96-sized array +/// A wrapper of 96-sized array #[derive(Clone, Copy, Eq, Hash, PartialEq, Serialize)] pub struct PublicKeyBytes( #[serde(serialize_with = "crate::serialize_b58")] pub [u8; PUBLIC_BLS_SIZE], @@ -141,8 +141,6 @@ impl Debug for PublicKeyBytes { } /// Loads consensus keys from an encrypted file. -/// -/// Panics on any error. pub fn load_keys( path: String, pwd: String, @@ -154,8 +152,6 @@ pub fn load_keys( } /// Fetches BLS public and secret keys from an encrypted consensus keys file. -/// -/// Panics on any error. fn read_from_file( path: PathBuf, pwd: &str, @@ -224,7 +220,7 @@ fn decrypt(data: &[u8], pwd: &[u8]) -> Result, BlockModeError> { /// Loads wallet files from $DUSK_WALLET_DIR and returns a vector of all loaded /// consensus keys. /// -/// It reads RUSK_WALLET_PWD var to unlock wallet files. +/// It reads $DUSK_CONSENSUS_KEYS_PASS var to unlock wallet files. pub fn load_provisioners_keys(n: usize) -> Vec<(BlsSecretKey, PublicKey)> { let mut keys = vec![]; diff --git a/node-data/src/encoding.rs b/node-data/src/encoding.rs index 0f9cafa486..95b987bf7a 100644 --- a/node-data/src/encoding.rs +++ b/node-data/src/encoding.rs @@ -65,10 +65,10 @@ impl Serializable for Block { impl Serializable for Transaction { fn write(&self, w: &mut W) -> io::Result<()> { - //Write version + // Write version w.write_all(&self.version.to_le_bytes())?; - //Write TxType + // Write TxType w.write_all(&self.r#type.to_le_bytes())?; let data = self.inner.to_var_bytes(); diff --git a/node-data/src/ledger/attestation.rs b/node-data/src/ledger/attestation.rs index 32b638c95f..edc8e3ed93 100644 --- a/node-data/src/ledger/attestation.rs +++ b/node-data/src/ledger/attestation.rs @@ -42,7 +42,7 @@ impl StepVotes { } } -/// a wrapper of 48-sized array to facilitate Signature +/// A wrapper of 48-sized array to facilitate Signature #[derive(Clone, Copy, Eq, Hash, PartialEq, Serialize)] pub struct Signature( #[serde(serialize_with = "crate::serialize_hex")] [u8; 48], @@ -83,7 +83,7 @@ impl Default for Signature { /// generator pub type IterationInfo = (Attestation, PublicKeyBytes); -/// Defines a set of attestations of any former iterations +/// Defines a set of attestations of former iterations #[derive(Default, Eq, PartialEq, Clone, Serialize)] #[serde(transparent)] pub struct IterationsInfo { diff --git a/node-data/src/ledger/block.rs b/node-data/src/ledger/block.rs index 9e691b3ff8..49273dd743 100644 --- a/node-data/src/ledger/block.rs +++ b/node-data/src/ledger/block.rs @@ -104,7 +104,7 @@ pub mod faker { use transaction::faker::gen_dummy_tx; impl Dummy for Block { - /// Creates a block with 3 transactions and random header. + /// Creates a block with 3 transactions and a random header. fn dummy_with_rng(_config: &T, rng: &mut R) -> Self { let txs = vec![ gen_dummy_tx(rng.gen()), diff --git a/node-data/src/message.rs b/node-data/src/message.rs index f0d893bcc0..9321e1b21c 100644 --- a/node-data/src/message.rs +++ b/node-data/src/message.rs @@ -79,7 +79,7 @@ impl Message { Payload::Validation(v) => v.get_step(), Payload::Ratification(r) => r.get_step(), Payload::Quorum(_) => { - // This should be removed in future + // TODO: This should be removed in future StepName::Ratification.to_step(self.header.iteration) } _ => StepName::Proposal.to_step(self.header.iteration), @@ -353,7 +353,7 @@ pub enum Payload { GetResource(payload::GetResource), // Internal messages payload - /// Result message passed from Validation step to Ratification step + // Result message passed from Validation step to Ratification step ValidationResult(Box), #[default] @@ -1074,8 +1074,6 @@ pub enum Topics { Candidate = 16, Validation = 17, Ratification = 18, - - // Consensus Quorum loop topics Quorum = 19, #[default] @@ -1132,9 +1130,7 @@ impl AsyncQueue { /// /// `Label` sets a queue label for logging /// - /// Panics - /// Capacity must be a positive number. If cap is zero, this function will - /// panic. + /// Panics if `cap` is zero (Capacity must be a positive number). pub fn bounded(cap: usize, label: &'static str) -> Self { let (sender, receiver) = async_channel::bounded(cap); Self {