Skip to content

Commit 6edd361

Browse files
committed
fix: clippy warnning manual_is_multiple_of
if blob_gas_used % DATA_GAS_PER_BLOB != 0 { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `!blob_gas_used.is_multiple_of(DATA_GAS_PER_BLOB)` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_multiple_of = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]` Signed-off-by: Jack Drogon <[email protected]>
1 parent f300160 commit 6edd361

File tree

11 files changed

+26
-22
lines changed

11 files changed

+26
-22
lines changed

crates/cli/commands/src/db/checksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<N: ProviderNodeTypes> TableViewer<(u64, Duration)> for ChecksumViewer<'_, N
111111
for (index, entry) in walker.enumerate() {
112112
let (k, v): (RawKey<T::Key>, RawValue<T::Value>) = entry?;
113113

114-
if index % 100_000 == 0 {
114+
if index.is_multiple_of(100_000) {
115115
info!("Hashed {index} entries.");
116116
}
117117

crates/consensus/common/src/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn validate_4844_header_standalone<H: BlockHeader>(
209209
return Err(ConsensusError::ParentBeaconBlockRootMissing)
210210
}
211211

212-
if blob_gas_used % DATA_GAS_PER_BLOB != 0 {
212+
if !blob_gas_used.is_multiple_of(DATA_GAS_PER_BLOB) {
213213
return Err(ConsensusError::BlobGasUsedNotMultipleOfBlobGasPerBlob {
214214
blob_gas_used,
215215
blob_gas_per_blob: DATA_GAS_PER_BLOB,

crates/era-utils/src/history.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ where
370370
for (index, hash_to_number) in hash_collector.iter()?.enumerate() {
371371
let (hash, number) = hash_to_number?;
372372

373-
if index != 0 && index % interval == 0 {
373+
if index != 0 && index.is_multiple_of(interval) {
374374
info!(target: "era::history::import", progress = %format!("{:.2}%", (index as f64 / total_headers as f64) * 100.0), "Writing headers hash index");
375375
}
376376

crates/stages/stages/src/stages/hashing_account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ where
180180
});
181181

182182
// Flush to ETL when channels length reaches MAXIMUM_CHANNELS
183-
if !channels.is_empty() && channels.len() % MAXIMUM_CHANNELS == 0 {
183+
if !channels.is_empty() && channels.len().is_multiple_of(MAXIMUM_CHANNELS) {
184184
collect(&mut channels, &mut collector)?;
185185
}
186186
}
@@ -193,7 +193,7 @@ where
193193
let total_hashes = collector.len();
194194
let interval = (total_hashes / 10).max(1);
195195
for (index, item) in collector.iter()?.enumerate() {
196-
if index > 0 && index % interval == 0 {
196+
if index > 0 && index.is_multiple_of(interval) {
197197
info!(
198198
target: "sync::stages::hashing_account",
199199
progress = %format!("{:.2}%", (index as f64 / total_hashes as f64) * 100.0),

crates/stages/stages/src/stages/hashing_storage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ where
110110
});
111111

112112
// Flush to ETL when channels length reaches MAXIMUM_CHANNELS
113-
if !channels.is_empty() && channels.len() % MAXIMUM_CHANNELS == 0 {
113+
if !channels.is_empty() && channels.len().is_multiple_of(MAXIMUM_CHANNELS) {
114114
collect(&mut channels, &mut collector)?;
115115
}
116116
}
@@ -121,7 +121,7 @@ where
121121
let interval = (total_hashes / 10).max(1);
122122
let mut cursor = tx.cursor_dup_write::<tables::HashedStorages>()?;
123123
for (index, item) in collector.iter()?.enumerate() {
124-
if index > 0 && index % interval == 0 {
124+
if index > 0 && index.is_multiple_of(interval) {
125125
info!(
126126
target: "sync::stages::hashing_storage",
127127
progress = %format!("{:.2}%", (index as f64 / total_hashes as f64) * 100.0),

crates/stages/stages/src/stages/headers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ where
119119
for (index, header) in self.header_collector.iter()?.enumerate() {
120120
let (_, header_buf) = header?;
121121

122-
if index > 0 && index % interval == 0 && total_headers > 100 {
122+
if index > 0 && index.is_multiple_of(interval) && total_headers > 100 {
123123
info!(target: "sync::stages::headers", progress = %format!("{:.2}%", (index as f64 / total_headers as f64) * 100.0), "Writing headers");
124124
}
125125

@@ -164,7 +164,7 @@ where
164164
for (index, hash_to_number) in self.hash_collector.iter()?.enumerate() {
165165
let (hash, number) = hash_to_number?;
166166

167-
if index > 0 && index % interval == 0 && total_headers > 100 {
167+
if index > 0 && index.is_multiple_of(interval) && total_headers > 100 {
168168
info!(target: "sync::stages::headers", progress = %format!("{:.2}%", (index as f64 / total_headers as f64) * 100.0), "Writing headers hash index");
169169
}
170170

crates/stages/stages/src/stages/tx_lookup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ where
154154
let interval = (total_hashes / 10).max(1);
155155
for (index, hash_to_number) in hash_collector.iter()?.enumerate() {
156156
let (hash, number) = hash_to_number?;
157-
if index > 0 && index % interval == 0 {
157+
if index > 0 && index.is_multiple_of(interval) {
158158
info!(
159159
target: "sync::stages::transaction_lookup",
160160
?append_only,

crates/stages/stages/src/stages/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ where
7777
let (block_number, key) = partial_key_factory(entry?);
7878
cache.entry(key).or_default().push(block_number);
7979

80-
if idx > 0 && idx % interval == 0 && total_changesets > 1000 {
80+
if idx > 0 && idx.is_multiple_of(interval) && total_changesets > 1000 {
8181
info!(target: "sync::stages::index_history", progress = %format!("{:.4}%", (idx as f64 / total_changesets as f64) * 100.0), "Collecting indices");
8282
}
8383

@@ -131,7 +131,7 @@ where
131131
let sharded_key = decode_key(k)?;
132132
let new_list = BlockNumberList::decompress_owned(v)?;
133133

134-
if index > 0 && index % interval == 0 && total_entries > 10 {
134+
if index > 0 && index.is_multiple_of(interval) && total_entries > 10 {
135135
info!(target: "sync::stages::index_history", progress = %format!("{:.2}%", (index as f64 / total_entries as f64) * 100.0), "Writing indices");
136136
}
137137

crates/storage/db-common/src/init.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ fn parse_accounts(
484484
let GenesisAccountWithAddress { genesis_account, address } = serde_json::from_str(&line)?;
485485
collector.insert(address, genesis_account)?;
486486

487-
if !collector.is_empty() && collector.len() % AVERAGE_COUNT_ACCOUNTS_PER_GB_STATE_DUMP == 0
487+
if !collector.is_empty() &&
488+
collector.len().is_multiple_of(AVERAGE_COUNT_ACCOUNTS_PER_GB_STATE_DUMP)
488489
{
489490
info!(target: "reth::cli",
490491
parsed_new_accounts=collector.len(),
@@ -523,7 +524,7 @@ where
523524

524525
accounts.push((address, account));
525526

526-
if (index > 0 && index % AVERAGE_COUNT_ACCOUNTS_PER_GB_STATE_DUMP == 0) ||
527+
if (index > 0 && index.is_multiple_of(AVERAGE_COUNT_ACCOUNTS_PER_GB_STATE_DUMP)) ||
527528
index == accounts_len - 1
528529
{
529530
total_inserted_accounts += accounts.len();
@@ -588,7 +589,7 @@ where
588589

589590
intermediate_state = Some(*state);
590591

591-
if total_flushed_updates % SOFT_LIMIT_COUNT_FLUSHED_UPDATES == 0 {
592+
if total_flushed_updates.is_multiple_of(SOFT_LIMIT_COUNT_FLUSHED_UPDATES) {
592593
info!(target: "reth::cli",
593594
total_flushed_updates,
594595
"Flushing trie updates"

crates/storage/provider/src/test_utils/blocks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ fn block4(
366366
for idx in address_range {
367367
let address = Address::with_last_byte(idx);
368368
// increase balance for every even account and destroy every odd
369-
bundle_state_builder = if idx % 2 == 0 {
369+
bundle_state_builder = if idx.is_multiple_of(2) {
370370
bundle_state_builder
371371
.state_present_account_info(
372372
address,
@@ -462,7 +462,7 @@ fn block5(
462462
.map(|slot| (U256::from(slot), (U256::from(slot), U256::from(slot * 4))))
463463
.collect(),
464464
);
465-
bundle_state_builder = if idx % 2 == 0 {
465+
bundle_state_builder = if idx.is_multiple_of(2) {
466466
bundle_state_builder
467467
.revert_account_info(
468468
number,

0 commit comments

Comments
 (0)