Skip to content

Commit

Permalink
style: fix clippy (kaspanet#510)
Browse files Browse the repository at this point in the history
* style: fix clippy

* relax the restriction to make ci green =)
  • Loading branch information
biryukovmaxim authored Jul 26, 2024
1 parent 56c19c9 commit 0feba1f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 27 deletions.
1 change: 1 addition & 0 deletions components/addressmanager/src/stores/address_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct Entry {
impl MemSizeEstimator for Entry {}

pub trait AddressesStoreReader {
#[allow(dead_code)]
fn get(&self, key: AddressKey) -> Result<Entry, StoreError>;
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/hashes/src/hashers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ macro_rules! sha256_hasher {
// SHA256 doesn't natively support domain separation, so we hash it to make it constant size.
let mut tmp_state = Sha256::new();
tmp_state.update($domain_sep);
let mut out = Self(Sha256::new());
let mut out = $name(Sha256::new());
out.write(tmp_state.finalize());

out
Expand Down
2 changes: 2 additions & 0 deletions crypto/muhash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ rand.workspace = true
name = "bench"
harness = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
3 changes: 2 additions & 1 deletion mining/src/block_template/model/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ impl CandidateList {
/// * tx1: start 0, end 100
/// * tx2: start 100, end 105
/// * tx3: start 105, end 2000
/// And r=102, then find will return tx2.
///
/// And r=102, then [`CandidateList::find`] will return tx2.
pub(crate) fn find(&self, r: f64) -> usize {
let mut min = 0;
let mut max = self.candidates.len() - 1;
Expand Down
6 changes: 3 additions & 3 deletions wallet/core/src/storage/local/transaction/fsio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl TransactionRecordStore for TransactionStore {
let mut transactions = vec![];

for id in ids {
let path = folder.join(&id.to_hex());
let path = folder.join(id.to_hex());
match read(&path, None).await {
Ok(tx) => {
transactions.push(Arc::new(tx));
Expand Down Expand Up @@ -144,7 +144,7 @@ impl TransactionRecordStore for TransactionStore {
let mut located = 0;

for id in ids {
let path = folder.join(&id.to_hex());
let path = folder.join(id.to_hex());

match read(&path, None).await {
Ok(tx) => {
Expand All @@ -167,7 +167,7 @@ impl TransactionRecordStore for TransactionStore {
let iter = ids.iter().skip(range.start).take(range.len());

for id in iter {
let path = folder.join(&id.to_hex());
let path = folder.join(id.to_hex());
match read(&path, None).await {
Ok(tx) => {
transactions.push(Arc::new(tx));
Expand Down
45 changes: 24 additions & 21 deletions wallet/core/src/tx/generator/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@
//! interface or via an async Stream interface.
//!
//! Q: Why is this not implemented as a single loop?
//!
//! A: There are a number of requirements that need to be handled:
//!
//! 1. UTXO entry consumption while creating inputs may results in
//! additional fees, requiring additional UTXO entries to cover
//! the fees. Goto 1. (this is a classic issue, can be solved using padding)
//! 1. UTXO entry consumption while creating inputs may result in
//! additional fees, requiring additional UTXO entries to cover
//! the fees. Goto 1. (this is a classic issue, can be solved using padding)
//!
//! 2. The overall design strategy for this processor is to allow
//! concurrent processing of a large number of transactions and UTXOs.
//! This implementation avoids in-memory aggregation of all
//! transactions that may result in OOM conditions.
//! 2. The overall design strategy for this processor is to allow
//! concurrent processing of a large number of transactions and UTXOs.
//! This implementation avoids in-memory aggregation of all
//! transactions that may result in OOM conditions.
//!
//! 3. If used with a large UTXO set, the transaction generation process
//! needs to be asynchronous to avoid blocking the main thread. In the
//! context of WASM32 SDK, not doing that while working with large
//! UTXO sets will result in a browser UI freezing.
//! 3. If used with a large UTXO set, the transaction generation process
//! needs to be asynchronous to avoid blocking the main thread. In the
//! context of WASM32 SDK, not doing that while working with large
//! UTXO sets will result in a browser UI freezing.
//!
use crate::imports::*;
Expand Down Expand Up @@ -553,16 +554,18 @@ impl Generator {
///
/// The general processing pattern can be described as follows:
///
/// loop {
/// 1. Obtain UTXO entry from [`Generator::get_utxo_entry()`]
/// 2. Check if UTXO entries have been depleted, if so, handle sweep processing.
/// 3. Create a new Input for the transaction from the UTXO entry.
/// 4. Check if the transaction mass threshold has been reached, if so, yield the transaction.
/// 5. Register input with the [`Data`] structures.
/// 6. Check if the final transaction amount has been reached, if so, yield the transaction.
/// }
///
///
/**
loop {
1. Obtain UTXO entry from [`Generator::get_utxo_entry()`]
2. Check if UTXO entries have been depleted, if so, handle sweep processing.
3. Create a new Input for the transaction from the UTXO entry.
4. Check if the transaction mass threshold has been reached, if so, yield the transaction.
5. Register input with the [`Data`] structures.
6. Check if the final transaction amount has been reached, if so, yield the transaction.
}
*/

fn generate_transaction_data(&self, context: &mut Context, stage: &mut Stage) -> Result<(DataKind, Data)> {
let calc = &self.inner.mass_calculator;
let mut data = Data::new(calc);
Expand Down
1 change: 1 addition & 0 deletions wallet/core/src/utxo/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ impl UtxoContext {
// remove UTXOs from account set

let outgoing_transactions = self.processor().outgoing();
#[allow(clippy::mutable_key_type)]
let mut accepted_outgoing_transactions = HashSet::<OutgoingTransaction>::new();

utxos.retain(|utxo| {
Expand Down
2 changes: 2 additions & 0 deletions wallet/core/src/utxo/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ impl UtxoProcessor {
Ok(())
}

#[allow(clippy::mutable_key_type)]
pub async fn handle_pending(&self, current_daa_score: u64) -> Result<()> {
let params = self.network_params()?;

Expand Down Expand Up @@ -388,6 +389,7 @@ impl UtxoProcessor {
pub async fn handle_utxo_changed(&self, utxos: UtxosChangedNotification) -> Result<()> {
let current_daa_score = self.current_daa_score().expect("DAA score expected when handling UTXO Changed notifications");

#[allow(clippy::mutable_key_type)]
let mut updated_contexts: HashSet<UtxoContext> = HashSet::default();

let removed = (*utxos.removed).clone().into_iter().filter_map(|entry| entry.address.clone().map(|address| (address, entry)));
Expand Down
2 changes: 1 addition & 1 deletion wasm/build/docs/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"treatWarningsAsErrors": false,
"cleanOutputDir": true,
"disableSources": true,
"categoryOrder": ["*", "Other"],
"categoryOrder": ["*", "Other"]
}

0 comments on commit 0feba1f

Please sign in to comment.