8000 v1.17: Uses stable `u64::next_multiple_of()` (backport of #33549) by mergify[bot] · Pull Request #33567 · solana-labs/solana · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

v1.17: Uses stable u64::next_multiple_of() (backport of #33549) #33567

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn test_background_services_request_handling_for_epoch_accounts_hash() {
// Based on the EAH start and snapshot interval, pick a slot to mass-root all the banks in
// this range such that an EAH request will be sent and also a snapshot request.
let eah_start_slot = epoch_accounts_hash_utils::calculation_start(&bank);
let set_root_slot = next_multiple_of(eah_start_slot, FULL_SNAPSHOT_INTERVAL);
let set_root_slot = eah_start_slot.next_multiple_of(FULL_SNAPSHOT_INTERVAL);

if bank.block_height() == set_root_slot {
info!("Calling set_root() on bank {}...", bank.slot());
Expand Down Expand Up @@ -661,16 +661,3 @@ fn test_epoch_accounts_hash_and_warping() {
.wait_get_epoch_accounts_hash();
info!("Waiting for epoch accounts hash... DONE");
}

// Copy the impl of `next_multiple_of` since it is nightly-only experimental.
// https://doc.rust-lang.org/std/primitive.u64.html#method.next_multiple_of
// https://github.com/rust-lang/rust/issues/88581
// https://github.com/rust-lang/rust/pull/88582
// https://github.com/jhpratt/rust/blob/727a4fc7e3f836938dfeb4a2ab237cfca612222d/library/core/src/num/uint_macros.rs#L1811-L1837
const fn next_multiple_of(lhs: u64, rhs: u64) -> u64 {
#![allow(clippy::arithmetic_side_effects)]
match lhs % rhs {
0 => lhs,
r => lhs + (rhs - r),
}
}
0