Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion common/src/balance_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Ord for BalanceUnit {

impl PartialOrd for BalanceUnit {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(&other))
Some(self.cmp(other))
}
}

Expand Down
20 changes: 13 additions & 7 deletions common/src/cache_storage/cache_double_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ where
_phantom: PhantomData<Storage>,
}

impl<Key1, Key2, Value, Storage> Default for CacheStorageDoubleMap<Key1, Key2, Value, Storage>
where
Key1: Ord + FullCodec + Clone,
Key2: Ord + FullCodec + Clone,
Value: FullCodec + Clone + PartialEq,
Storage: IterableStorageDoubleMap<Key1, Key2, Value>,
{
fn default() -> Self {
Self::new()
}
}

impl<Key1, Key2, Value, Storage> CacheStorageDoubleMap<Key1, Key2, Value, Storage>
where
Key1: Ord + FullCodec + Clone,
Expand Down Expand Up @@ -170,13 +182,7 @@ where
}
}

second_map.retain(|_, v| {
if let Some(Item::Original(_)) = v {
true
} else {
false
}
});
second_map.retain(|_, v| matches!(v, Some(Item::Original(_))));
}
}

Expand Down
22 changes: 14 additions & 8 deletions common/src/cache_storage/cache_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,18 @@ where
_phantom: PhantomData<Storage>,
}

impl<Key: Ord, Value, Storage> CacheStorageMap<Key, Value, Storage>
impl<Key, Value, Storage> Default for CacheStorageMap<Key, Value, Storage>
where
Key: Ord + FullEncode + Clone,
Value: FullCodec + Clone + PartialEq,
Storage: StorageMap<Key, Value>,
{
fn default() -> Self {
Self::new()
}
}

impl<Key, Value, Storage> CacheStorageMap<Key, Value, Storage>
where
Key: Ord + FullEncode + Clone,
Value: FullCodec + Clone + PartialEq,
Expand Down Expand Up @@ -134,13 +145,8 @@ where
}
}
}
self.cache.retain(|_, v| {
if let Some(Item::Original(_)) = v {
true
} else {
false
}
});
self.cache
.retain(|_, v| matches!(v, Some(Item::Original(_))));
}

/// Resets the cache
Expand Down
7 changes: 3 additions & 4 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO #167: fix clippy warnings
#![allow(clippy::all)]
#![allow(clippy::type_complexity)]

#[macro_use]
extern crate alloc;
Expand Down Expand Up @@ -191,13 +190,13 @@ pub fn convert_block_number_to_timestamp<T: Config + pallet_timestamp::Config>(
let num_of_seconds: u32 =
((unlocking_block - current_block) * 6u32.into()).unique_saturated_into();
let mut timestamp: T::Moment = num_of_seconds.into();
timestamp = timestamp * 1000u32.into();
timestamp *= 1000u32.into();
current_timestamp + timestamp
} else {
let num_of_seconds: u32 =
((current_block - unlocking_block) * 6u32.into()).unique_saturated_into();
let mut timestamp: T::Moment = num_of_seconds.into();
timestamp = timestamp * 1000u32.into();
timestamp *= 1000u32.into();
current_timestamp - timestamp
}
}
Loading