Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion crates/starknet_committer_cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ fn apply_interference<S: AsyncStorage>(
n_updates_arg: usize,
block_number: usize,
task_set: &mut JoinSet<()>,
mut storage: S,
storage: S,
rng: &mut SmallRng,
) {
match interference_type {
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_patricia_storage/src/aerospike_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Storage for AerospikeStorage {
type Stats = NoStats;
type Config = EmptyStorageConfig;

async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
let record = self
.client
.get(&self.config.read_policy, &self.get_key(key.clone())?, Bins::All)
Expand All @@ -143,7 +143,7 @@ impl Storage for AerospikeStorage {
.await?)
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
let mut ops = Vec::new();
for key in keys.iter() {
ops.push(BatchOperation::read(
Expand Down
8 changes: 4 additions & 4 deletions crates/starknet_patricia_storage/src/map_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ impl Storage for MapStorage {
Ok(())
}

async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
Ok(self.0.get(key).cloned())
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
Ok(keys.iter().map(|key| self.0.get(key).cloned()).collect())
}

Expand Down Expand Up @@ -227,7 +227,7 @@ impl<S: Storage> Storage for CachedStorage<S> {
type Stats = CachedStorageStats<S::Stats>;
type Config = CachedStorageConfig<S::Config>;

async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
self.reads.fetch_add(1, Ordering::Relaxed);
if let Some(cached_value) = self.cache.peek(key) {
self.cached_reads.fetch_add(1, Ordering::Relaxed);
Expand All @@ -245,7 +245,7 @@ impl<S: Storage> Storage for CachedStorage<S> {
Ok(())
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
let mut values = vec![None; keys.len()]; // The None values are placeholders.
let mut keys_to_fetch = Vec::new();
let mut indices_to_fetch = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_patricia_storage/src/mdbx_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Storage for MdbxStorage {
type Stats = MdbxStorageStats;
type Config = EmptyStorageConfig;

async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
let txn = self.db.begin_ro_txn()?;
let table = txn.open_table(None)?;
Ok(txn.get(&table, &key.0)?.map(DbValue))
Expand All @@ -116,7 +116,7 @@ impl Storage for MdbxStorage {
Ok(())
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
let txn = self.db.begin_ro_txn()?;
let table = txn.open_table(None)?;
let mut res = Vec::with_capacity(keys.len());
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_patricia_storage/src/rocksdb_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ impl Storage for RocksDbStorage {
type Stats = RocksDbStats;
type Config = RocksDbStorageConfig;

async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
Ok(self.db.get(&key.0)?.map(DbValue))
}

async fn set(&mut self, key: DbKey, value: DbValue) -> PatriciaStorageResult<()> {
Ok(self.db.put_opt(&key.0, &value.0, &self.options.write_options)?)
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
let raw_keys = keys.iter().map(|k| &k.0);
let res = self
.db
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_patricia_storage/src/short_key_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ macro_rules! define_short_key_storage {
type Stats = S::Stats;
type Config = EmptyStorageConfig;

async fn get(&mut self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
self.storage.get(&Self::small_key(key)).await
}

async fn set(&mut self, key: DbKey, value: DbValue) -> PatriciaStorageResult<()> {
self.storage.set(Self::small_key(&key), value).await
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
let small_keys = keys
.iter()
.map(|key| Self::small_key(key))
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_patricia_storage/src/storage_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn test_storage_concurrent_access(#[case] mut storage: impl AsyncStorage)
// Parallel reads from the storage while some writes are happening.
let mut tasks = JoinSet::new();
for i in 0..10u8 {
let mut cloned_storage = storage.clone();
let cloned_storage = storage.clone();
tasks.spawn(async move {
let result = cloned_storage.get(&DbKey(vec![i])).await.unwrap().unwrap().0[0];
// The result is either the original value or the new value.
Expand Down
8 changes: 4 additions & 4 deletions crates/starknet_patricia_storage/src/storage_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub trait Storage: Send + Sync {
// https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#async-fn-in-public-traits
// for details.
fn get(
&mut self,
&self,
key: &DbKey,
) -> impl Future<Output = PatriciaStorageResult<Option<DbValue>>> + Send;

Expand All @@ -123,7 +123,7 @@ pub trait Storage: Send + Sync {
// https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#async-fn-in-public-traits
// for details.
fn mget(
&mut self,
&self,
keys: &[&DbKey],
) -> impl Future<Output = PatriciaStorageResult<Vec<Option<DbValue>>>> + Send;

Expand Down Expand Up @@ -185,15 +185,15 @@ impl Storage for NullStorage {
type Stats = NoStats;
type Config = EmptyStorageConfig;

async fn get(&mut self, _key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
async fn get(&self, _key: &DbKey) -> PatriciaStorageResult<Option<DbValue>> {
Ok(None)
}

async fn set(&mut self, _key: DbKey, _value: DbValue) -> PatriciaStorageResult<()> {
Ok(())
}

async fn mget(&mut self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
async fn mget(&self, keys: &[&DbKey]) -> PatriciaStorageResult<Vec<Option<DbValue>>> {
Ok(vec![None; keys.len()])
}

Expand Down
Loading