Explorar el Código

chore: clippy too_long_first_doc_paragraph fixed almost everywhere

skoupidi hace 1 año
padre
commit
6a39547118

+ 8 - 4
src/blockchain/block_store.rs

@@ -35,6 +35,7 @@ use crate::{tx::Transaction, util::time::Timestamp, Error, Result};
 use super::{parse_record, parse_u32_key_record, Header, HeaderHash, SledDbOverlayPtr};
 
 /// This struct represents a tuple of the form (`header`, `txs`, `signature`).
+///
 /// The header and transactions are stored as hashes, serving as pointers to the actual data
 /// in the sled database.
 /// NOTE: This struct fields are considered final, as it represents a blockchain block.
@@ -67,10 +68,11 @@ impl Block {
     }
 }
 
-/// Structure representing full block data, acting as
-/// a wrapper struct over `Block`, enabling us to include
-/// more information that might be used in different block
-/// version, without affecting the original struct.
+/// Structure representing full block data.
+///
+/// It acts as a wrapper struct over `Block`, enabling us
+/// to include more information that might be used in different
+/// block versions, without affecting the original struct.
 #[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
 pub struct BlockInfo {
     /// Block header data
@@ -161,6 +163,7 @@ pub struct BlockOrder {
 }
 
 /// Auxiliary structure used to keep track of block ranking information.
+///
 /// Note: we only need height cummulative ranks, but we also keep its actual
 /// ranks, so we can verify the sequence and/or know specific block height
 /// ranks, if ever needed.
@@ -188,6 +191,7 @@ impl BlockRanks {
 }
 
 /// Auxiliary structure used to keep track of block PoW difficulty information.
+///
 /// Note: we only need height cummulative difficulty, but we also keep its actual
 /// difficulty, so we can verify the sequence and/or know specific block height
 /// difficulty, if ever needed.

+ 2 - 1
src/contract/money/src/client/mod.rs

@@ -64,7 +64,8 @@ pub mod auth_token_freeze_v1;
 /// `Money::TokenMintV1` API
 pub mod token_mint_v1;
 
-/// `MoneyNote` holds the inner attributes of a `Coin`
+/// `MoneyNote` holds the inner attributes of a `Coin`.
+///
 /// It does not store the public key since it's encrypted for that key,
 /// and so is not needed to infer the coin attributes.
 /// All other coin attributes must be present.

+ 3 - 1
src/geode/mod.rs

@@ -78,7 +78,9 @@ const FILES_PATH: &str = "files";
 const CHUNKS_PATH: &str = "chunks";
 
 /// `ChunkedFile` is a representation of a file we're trying to
-/// retrieve from `Geode`. The tuple contains `blake3::Hash` of
+/// retrieve from `Geode`.
+///
+/// The tuple contains `blake3::Hash` of
 /// the file's chunks and an optional `PathBuf` which points to
 /// the filesystem where the chunk can be found. If `None`, it
 /// is to be assumed that the chunk is not available locally.

+ 7 - 5
src/net/hosts.rs

@@ -843,11 +843,13 @@ impl HostContainer {
 }
 
 /// Main parent class for the management and manipulation of
-/// hostlists. Keeps track of hosts and their current state via the
-/// HostRegistry, and stores hostlists and associated methods in the
-/// HostContainer. Also operates two publishers to notify other parts
-/// of the code base when new channels have been created or new hosts
-/// have been added to the hostlist.
+/// hostlists.
+///
+/// Keeps track of hosts and their current state via the HostRegistry,
+/// and stores hostlists and associated methods in the HostContainer.
+/// Also operates two publishers to notify other parts of the code base
+/// when new channels have been created or new hosts have been added to
+/// the hostlist.
 pub struct Hosts {
     /// A registry that tracks hosts and their current state.
     registry: HostRegistry,

+ 11 - 6
src/net/mod.rs

@@ -29,9 +29,11 @@ pub mod message;
 pub use message::Message;
 
 /// Generic publish/subscribe class that can dispatch any kind of message
-/// to a subscribed list of dispatchers. Dispatchers subscribe to a single
-/// message format of any type. This is a generalized version of the simple
-/// publish-subscribe class in system::Publisher.
+/// to a subscribed list of dispatchers.
+///
+/// Dispatchers subscribe to a single message format of any type. This is
+/// a generalized version of the simple publish-subscribe class in
+/// system::Publisher.
 ///
 /// Message Subsystem also enables the creation of new message subsystems,
 /// adding new dispatchers and clearing inactive channels.
@@ -54,9 +56,11 @@ pub use message_publisher::MessageSubscription;
 pub mod transport;
 
 /// Hosts are a list of network addresses used when establishing outbound
-/// connections. Hosts are shared across the network through the address
-/// protocol. When attempting to connect, a node will loop through addresses
-/// in the hosts store until it finds ones to connect to.
+/// connections.
+///
+/// Hosts are shared across the network through the address protocol.
+/// When attempting to connect, a node will loop through addresses in the
+/// hosts store until it finds ones to connect to.
 pub mod hosts;
 
 /// Async channel that handles the sending of messages across the network.
@@ -97,6 +101,7 @@ pub use protocol::{
 };
 
 /// Defines the interaction between nodes during a connection.
+///
 /// Consists of an inbound session, which describes how to set up an
 /// incoming connection, and an outbound session, which describes setting
 /// up an outbound connection. Also describes the sesd session, which is

+ 16 - 12
src/net/protocol/mod.rs

@@ -21,10 +21,11 @@ use super::{
     session::{SESSION_DEFAULT, SESSION_SEED},
 };
 
-/// Manages the tasks for the network protocol. Used by other connection
-/// protocols to handle asynchronous task execution across the network.
-/// Runs all tasks that are handed to it on an executor that has stopping
-/// functionality.
+/// Manages the tasks for the network protocol.
+///
+/// Used by other connection protocols to handle asynchronous task execution
+/// across the network. Runs all tasks that are handed to it on an executor
+/// that has stopping functionality.
 pub mod protocol_jobs_manager;
 
 /// Protocol for version information handshake between nodes at the start
@@ -38,17 +39,20 @@ pub mod protocol_jobs_manager;
 pub mod protocol_version;
 pub use protocol_version::ProtocolVersion;
 
-/// Protocol for ping-pong keepalive messages. Implements ping message and
-/// pong response. These messages are like the network heartbeat - they are
-/// sent continually between nodes, to ensure each node is still alive and
-/// active. Ping-pong messages ensure that the network doesn't time out.
+/// Protocol for ping-pong keepalive messages.
+///
+/// Implements ping message and pong response. These messages are like the
+/// network heartbeat - they are sent continually between nodes, to ensure
+/// each node is still alive and active. Ping-pong messages ensure that the
+/// network doesn't time out.
 pub mod protocol_ping;
 pub use protocol_ping::ProtocolPing;
 
-/// Protocol for address and get-address messages. Implements how nodes
-/// exchange connection information about other nodes on the network.
-/// Address and get-address messages are exchanged continually alongside
-/// ping-pong messages as part of a network connection.
+/// Protocol for address and get-address messages.
+///
+/// Implements how nodes exchange connection information about other nodes
+/// on the network. Address and get-address messages are exchanged continually
+/// alongside ping-pong messages as part of a network connection.
 ///
 /// Protocol starts by creating a subscription to address and get-address
 /// messages. Then the protocol sends out a get-address message and waits

+ 5 - 3
src/net/protocol/protocol_address.rs

@@ -37,9 +37,11 @@ use super::{
 };
 use crate::{Error, Result};
 
-/// Defines address and get-address messages. On receiving GetAddr, nodes
-/// reply an AddrMessage containing nodes from their hostlist.  On receiving
-/// an AddrMessage, nodes enter the info into their greylists.
+/// Defines address and get-address messages.
+///
+/// On receiving GetAddr, nodes reply an AddrMessage containing nodes from
+/// their hostlist.  On receiving an AddrMessage, nodes enter the info into
+/// their greylists.
 ///
 /// The node selection logic for creating an AddrMessage is as follows:
 ///

+ 1 - 0
src/net/session/seedsync_session.rs

@@ -17,6 +17,7 @@
  */
 
 //! Seed sync session creates a connection to the seed nodes specified in settings.
+//!
 //! A new seed sync session is created every time we call [`P2p::start()`]. The
 //! seed sync session loops through all the configured seeds and creates a corresponding
 //! `Slot`. `Slot`'s are started, but sit in a suspended state until they are activated

+ 3 - 1
src/net/settings.rs

@@ -21,7 +21,9 @@ use url::Url;
 
 type BlacklistEntry = (String, Vec<String>, Vec<u16>);
 
-/// Ban policy which if set to `Relaxed` will not ban peers if the case
+/// Ban policies definitions.
+///
+/// If the ban policy is set to `Relaxed` will not ban peers in case
 /// they send a message without a corresponding MessageDispatcher.
 /// This is useful for nodes that may not be subscribed to protocols,
 /// such as Lilith. For most uses this should be set to `Strict`.

+ 1 - 0
src/rpc/clock_sync.rs

@@ -52,6 +52,7 @@ pub async fn ntp_request() -> Result<Timestamp> {
 }
 
 /// This is a very simple check to verify that the system time is correct.
+///
 /// Retry loop is used in case discrepancies are found.
 /// If all retries fail, system clock is considered invalid.
 /// TODO: 1. Add proxy functionality in order not to leak connections

+ 1 - 0
src/sdk/src/blockchain.rs

@@ -43,6 +43,7 @@ pub fn block_epoch(height: u32) -> u8 {
 }
 
 /// Auxiliary function to calculate provided block height expected reward value.
+///
 /// Genesis block always returns reward value 0. Rewards are halfed at fixed intervals,
 /// called epochs. After last epoch has started, reward value is based on DARK token-economics.
 pub fn expected_reward(height: u32) -> u64 {

+ 6 - 4
src/sdk/src/dark_tree.rs

@@ -24,8 +24,9 @@ use darkfi_serial::{SerialDecodable, SerialEncodable};
 
 use crate::error::{DarkTreeError, DarkTreeResult};
 
-/// This struct represents the information hold by a
-/// [`DarkTreeLeaf`], namely its data, along with positional
+/// Struct representing the information hold by a [`DarkTreeLeaf`].
+///
+/// This includes its data, along with positional
 /// indexes information, based on tree's traversal order.
 /// These indexes are only here to enable referencing
 /// connected nodes, and are *not* used as pointers by the
@@ -85,8 +86,9 @@ impl<T: Clone + Send + Sync> DarkTreeLeaf<T> {
     }
 }
 
-/// This struct represents a Tree using DFS post-order traversal,
-/// where when we iterate through the tree, we first process tree
+/// This struct represents a DFS post-order traversal Tree.
+///
+/// When we iterate through the tree, we first process tree
 /// node's children, and then the node itself, recursively.
 /// Based on this, initial tree node (leaf), known as the root,
 /// will always show up at the end of iteration. It is advised

+ 1 - 0
src/serial/src/lib.rs

@@ -269,6 +269,7 @@ impl_int_encodable!(i64, read_i64, write_i64);
 impl_int_encodable!(i128, read_i128, write_i128);
 
 /// Variable-integer encoding.
+///
 /// Integer can be encoded depending on the represented value to save space.
 /// Variable length integers always precede an array/vector of a type of data
 /// that may vary in length. Longer numbers are encoded in little endian.

+ 3 - 2
src/tx/mod.rs

@@ -51,8 +51,9 @@ macro_rules! zip {
 
 // ANCHOR: transaction
 /// A Transaction contains an arbitrary number of `ContractCall` objects,
-/// along with corresponding ZK proofs and Schnorr signatures. `DarkLeaf`
-/// is used to map relations between contract calls in the transaction.
+/// along with corresponding ZK proofs and Schnorr signatures.
+///
+/// `DarkLeaf` is used to map relations between contract calls in the transaction.
 #[derive(Clone, Default, Eq, PartialEq, SerialEncodable, SerialDecodable)]
 pub struct Transaction {
     /// Calls executed in this transaction

+ 4 - 3
src/util/cli.rs

@@ -112,9 +112,10 @@ pub fn get_log_config(verbosity_level: u8) -> simplelog::Config {
 }
 
 /// This macro is used for a standard way of daemonizing darkfi binaries
-/// with TOML config file configuration, and argument parsing. It also
-/// spawns a multithreaded async executor and passes it into the given
-/// function.
+/// with TOML config file configuration, and argument parsing.
+///
+/// It also spawns a multithreaded async executor and passes it into the
+/// given function.
 ///
 /// The Cargo.toml dependencies needed for this are:
 /// ```text

+ 5 - 4
src/validator/consensus.rs

@@ -587,10 +587,11 @@ impl From<Proposal> for BlockInfo {
     }
 }
 
-/// This struct represents a forked blockchain state, using an overlay over original
-/// blockchain, containing all pending to-write records. Additionally, each fork
-/// keeps a vector of valid pending transactions hashes, in order of receival, and
-/// the proposals hashes sequence, for validations.
+/// Struct representing a forked blockchain state.
+///
+/// An overlay over the original blockchain is used, containing all pending to-write
+/// records. Additionally, each fork keeps a vector of valid pending transactions hashes,
+/// in order of receival, and the proposals hashes sequence, for validations.
 #[derive(Clone)]
 pub struct Fork {
     /// Canonical (finalized) blockchain

+ 3 - 0
src/validator/utils.rs

@@ -32,6 +32,7 @@ use crate::{
 };
 
 /// Deploy DarkFi native wasm contracts to provided blockchain overlay.
+///
 /// If overlay already contains the contracts, it will just open the
 /// necessary db and trees, and give back what it has. This means that
 /// on subsequent runs, our native contracts will already be in a deployed
@@ -108,6 +109,7 @@ pub async fn deploy_native_contracts(
 }
 
 /// Compute a block's rank, assuming that its valid, based on provided mining target.
+///
 /// Block's rank is the tuple of its squared mining target distance from max 32 bytes int,
 /// along with its squared RandomX hash number distance from max 32 bytes int.
 /// Genesis block has rank (0, 0).
@@ -194,6 +196,7 @@ pub fn find_extended_fork_index(forks: &[Fork], proposal: &Proposal) -> Result<(
 }
 
 /// Auxiliary function to find best ranked fork.
+///
 /// The best ranked fork is the one with the highest sum of
 /// its blocks squared mining target distances, from max 32
 /// bytes int. In case of a tie, the fork with the highest

+ 10 - 4
src/validator/verification.rs

@@ -115,6 +115,8 @@ pub async fn verify_genesis_block(
     Ok(())
 }
 
+/// Validate provided block according to set rules.
+///
 /// A block is considered valid when the following rules apply:
 ///     1. Block version is correct for its height
 ///     2. Parent hash is equal to the hash of the previous block
@@ -319,9 +321,11 @@ pub fn verify_producer_signature(block: &BlockInfo, public_key: &PublicKey) -> R
     Ok(())
 }
 
-/// Verify WASM execution, signatures, and ZK proofs for a given producer [`Transaction`],
-/// and apply it to the provided overlay. Returns transaction signature public key.
-/// Additionally, append its hash to the provided Merkle tree.
+/// Verify provided producer producer [`Transaction`].
+///
+/// Verify WASM execution, signatures, and ZK proofs and apply it to the provided,
+/// provided overlay. Returns transaction signature public key. Additionally,
+/// append its hash to the provided Merkle tree.
 pub async fn verify_producer_transaction(
     overlay: &BlockchainOverlayPtr,
     verifying_block_height: u32,
@@ -875,6 +879,7 @@ async fn apply_transaction(
 }
 
 /// Verify a set of [`Transaction`] in sequence and apply them if all are valid.
+///
 /// In case any of the transactions fail, they will be returned to the caller as an error.
 /// If all transactions are valid, the function will return the total gas used and total
 /// paid fees from all the transactions. Additionally, their hash is appended to the provided
@@ -992,7 +997,8 @@ async fn apply_transactions(
     Ok(())
 }
 
-/// Verify given [`Proposal`] against provided consensus state,
+/// Verify given [`Proposal`] against provided consensus state.
+///
 /// A proposal is considered valid when the following rules apply:
 ///     1. Proposal hash matches the actual block one
 ///     2. Block transactions don't exceed set limit