mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 18:01:04 +00:00
Prepare for latest clippy (nightly 09-10-2022) (#12466)
This commit is contained in:
@@ -63,7 +63,7 @@ impl Era {
|
||||
/// does not exceed `BlockHashCount` parameter passed to `system` module, since that
|
||||
/// prunes old blocks and renders transactions immediately invalid.
|
||||
pub fn mortal(period: u64, current: u64) -> Self {
|
||||
let period = period.checked_next_power_of_two().unwrap_or(1 << 16).max(4).min(1 << 16);
|
||||
let period = period.checked_next_power_of_two().unwrap_or(1 << 16).clamp(4, 1 << 16);
|
||||
let phase = current % period;
|
||||
let quantize_factor = (period >> 12).max(1);
|
||||
let quantized_phase = phase / quantize_factor * quantize_factor;
|
||||
@@ -105,7 +105,7 @@ impl Encode for Era {
|
||||
Self::Immortal => output.push_byte(0),
|
||||
Self::Mortal(period, phase) => {
|
||||
let quantize_factor = (*period as u64 >> 12).max(1);
|
||||
let encoded = (period.trailing_zeros() - 1).max(1).min(15) as u16 |
|
||||
let encoded = (period.trailing_zeros() - 1).clamp(1, 15) as u16 |
|
||||
((phase / quantize_factor) << 4) as u16;
|
||||
encoded.encode_to(output);
|
||||
},
|
||||
|
||||
@@ -77,8 +77,8 @@ const STORAGE_LOCK_DEFAULT_EXPIRY_DURATION: Duration = Duration::from_millis(20_
|
||||
const STORAGE_LOCK_DEFAULT_EXPIRY_BLOCKS: u32 = 4;
|
||||
|
||||
/// Time between checks if the lock is still being held in milliseconds.
|
||||
const STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MIN: Duration = Duration::from_millis(100);
|
||||
const STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MAX: Duration = Duration::from_millis(10);
|
||||
const STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MIN: Duration = Duration::from_millis(10);
|
||||
const STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MAX: Duration = Duration::from_millis(100);
|
||||
|
||||
/// Lockable item for use with a persisted storage lock.
|
||||
///
|
||||
@@ -137,10 +137,9 @@ impl Lockable for Time {
|
||||
let remainder: Duration = now.diff(deadline);
|
||||
// do not snooze the full duration, but instead snooze max 100ms
|
||||
// it might get unlocked in another thread
|
||||
use core::cmp::{max, min};
|
||||
let snooze = max(
|
||||
min(remainder, STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MAX),
|
||||
let snooze = remainder.clamp(
|
||||
STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MIN,
|
||||
STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MAX,
|
||||
);
|
||||
sp_io::offchain::sleep_until(now.add(snooze));
|
||||
}
|
||||
@@ -239,10 +238,9 @@ impl<B: BlockNumberProvider> Lockable for BlockAndTime<B> {
|
||||
fn snooze(deadline: &Self::Deadline) {
|
||||
let now = offchain::timestamp();
|
||||
let remainder: Duration = now.diff(&(deadline.timestamp));
|
||||
use core::cmp::{max, min};
|
||||
let snooze = max(
|
||||
min(remainder, STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MAX),
|
||||
let snooze = remainder.clamp(
|
||||
STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MIN,
|
||||
STORAGE_LOCK_PER_CHECK_ITERATION_SNOOZE_MAX,
|
||||
);
|
||||
sp_io::offchain::sleep_until(now.add(snooze));
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ where
|
||||
fn from((inners, state_version): (Storage, StateVersion)) -> Self {
|
||||
let mut inner: HashMap<Option<ChildInfo>, BTreeMap<StorageKey, StorageValue>> = inners
|
||||
.children_default
|
||||
.into_iter()
|
||||
.map(|(_k, c)| (Some(c.child_info), c.data))
|
||||
.into_values()
|
||||
.map(|c| (Some(c.child_info), c.data))
|
||||
.collect();
|
||||
inner.insert(None, inners.top);
|
||||
(inner, state_version).into()
|
||||
|
||||
@@ -474,7 +474,7 @@ impl OverlayedChanges {
|
||||
pub fn children(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (impl Iterator<Item = (&StorageKey, &OverlayedValue)>, &ChildInfo)> {
|
||||
self.children.iter().map(|(_, v)| (v.0.changes(), &v.1))
|
||||
self.children.values().map(|v| (v.0.changes(), &v.1))
|
||||
}
|
||||
|
||||
/// Get an iterator over all top changes as been by the current transaction.
|
||||
|
||||
@@ -109,7 +109,7 @@ impl<H: Hasher> Recorder<H> {
|
||||
/// Returns the [`StorageProof`].
|
||||
pub fn to_storage_proof(&self) -> StorageProof {
|
||||
let recorder = self.inner.lock();
|
||||
StorageProof::new(recorder.accessed_nodes.iter().map(|(_, v)| v.clone()))
|
||||
StorageProof::new(recorder.accessed_nodes.values().cloned())
|
||||
}
|
||||
|
||||
/// Returns the estimated encoded size of the proof.
|
||||
|
||||
Reference in New Issue
Block a user