mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: ShardedKey::last helper methods (#3352)
This commit is contained in:
@ -29,6 +29,12 @@ impl<T> ShardedKey<T> {
|
||||
pub fn new(key: T, highest_block_number: BlockNumber) -> Self {
|
||||
ShardedKey { key, highest_block_number }
|
||||
}
|
||||
|
||||
/// Creates a new key with the highest block number set to maximum.
|
||||
/// This is useful when we want to search the last value for a given key.
|
||||
pub fn last(key: T) -> Self {
|
||||
Self { key, highest_block_number: u64::MAX }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Encode for ShardedKey<T>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
//! Sharded key
|
||||
//! Storage sharded key
|
||||
|
||||
use crate::{
|
||||
table::{Decode, Encode},
|
||||
@ -32,6 +32,15 @@ impl StorageShardedKey {
|
||||
pub fn new(address: H160, storage_key: H256, highest_block_number: BlockNumber) -> Self {
|
||||
Self { address, sharded_key: ShardedKey { key: storage_key, highest_block_number } }
|
||||
}
|
||||
|
||||
/// Creates a new key with the highest block number set to maximum.
|
||||
/// This is useful when we want to search the last value for a given key.
|
||||
pub fn last(address: H160, storage_key: H256) -> Self {
|
||||
Self {
|
||||
address,
|
||||
sharded_key: ShardedKey { key: storage_key, highest_block_number: u64::MAX },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Encode for StorageShardedKey {
|
||||
|
||||
Reference in New Issue
Block a user