Skip to content

Commit 7406aec

Browse files
authored
Rename clone_with_root_key (#4036)
## Motivation It was raised that the naming of this function is a bit misleading ## Proposal Attempt a better name ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle.
1 parent f0745f4 commit 7406aec

File tree

18 files changed

+48
-43
lines changed

18 files changed

+48
-43
lines changed

linera-indexer/lib/src/indexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ where
6565
pub async fn load(store: S) -> Result<Self, IndexerError> {
6666
let root_key = "indexer".as_bytes().to_vec();
6767
let store = store
68-
.clone_with_root_key(&root_key)
68+
.open_exclusive(&root_key)
6969
.map_err(|_e| IndexerError::CloneWithRootKeyError)?;
7070
let context = ViewContext::create_root_context(store, ())
7171
.await

linera-indexer/lib/src/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ where
7373
{
7474
let root_key = name.as_bytes().to_vec();
7575
let store = store
76-
.clone_with_root_key(&root_key)
76+
.open_exclusive(&root_key)
7777
.map_err(|_e| IndexerError::CloneWithRootKeyError)?;
7878
let context = ViewContext::create_root_context(store, ())
7979
.await

linera-storage-service/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl AdminKeyValueStore for ServiceStoreClientInternal {
438438
})
439439
}
440440

441-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, ServiceStoreError> {
441+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, ServiceStoreError> {
442442
let channel = self.channel.clone();
443443
let prefix_len = self.prefix_len;
444444
let semaphore = self.semaphore.clone();

linera-storage/src/db_storage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ where
554554
user_services: self.user_services.clone(),
555555
};
556556
let root_key = bcs::to_bytes(&BaseKey::ChainState(chain_id))?;
557-
let store = self.store.clone_with_root_key(&root_key)?;
557+
let store = self.store.open_exclusive(&root_key)?;
558558
let context = ViewContext::create_root_context(store, runtime_context).await?;
559559
ChainStateView::load(context).await
560560
}
@@ -946,7 +946,7 @@ where
946946
block_exporter_id: u32,
947947
) -> Result<Self::BlockExporterContext, ViewError> {
948948
let root_key = bcs::to_bytes(&BaseKey::BlockExporterState(block_exporter_id))?;
949-
let store = self.store.clone_with_root_key(&root_key)?;
949+
let store = self.store.open_exclusive(&root_key)?;
950950
Ok(ViewContext::create_root_context(store, block_exporter_id).await?)
951951
}
952952
}

linera-views/src/backends/dual.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ where
260260
})
261261
}
262262

263-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, Self::Error> {
263+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, Self::Error> {
264264
let first_store = self
265265
.first_store
266-
.clone_with_root_key(root_key)
266+
.open_exclusive(root_key)
267267
.map_err(DualStoreError::First)?;
268268
let second_store = self
269269
.second_store
270-
.clone_with_root_key(root_key)
270+
.open_exclusive(root_key)
271271
.map_err(DualStoreError::Second)?;
272272
let store_in_use = A::assigned_store(root_key)?;
273273
Ok(Self {

linera-views/src/backends/dynamo_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl AdminKeyValueStore for DynamoDbStoreInternal {
368368
Ok(store)
369369
}
370370

371-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, DynamoDbStoreInternalError> {
371+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, DynamoDbStoreInternalError> {
372372
let client = self.client.clone();
373373
let namespace = self.namespace.clone();
374374
let semaphore = self.semaphore.clone();

linera-views/src/backends/indexed_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl AdminKeyValueStore for IndexedDbStore {
279279
Self::connect_internal(config, namespace, start_key).await
280280
}
281281

282-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, IndexedDbStoreError> {
282+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, IndexedDbStoreError> {
283283
let database = self.database.clone();
284284
let object_store_name = self.object_store_name.clone();
285285
let max_stream_queries = self.max_stream_queries;

linera-views/src/backends/journaling.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ where
194194
})
195195
}
196196

197-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, Self::Error> {
198-
let store = self.store.clone_with_root_key(root_key)?;
197+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, Self::Error> {
198+
let store = self.store.open_exclusive(root_key)?;
199199
Ok(Self {
200200
store,
201201
has_exclusive_access: true,

linera-views/src/backends/lru_caching.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ where
487487
))
488488
}
489489

490-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, Self::Error> {
491-
let store = self.store.clone_with_root_key(root_key)?;
490+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, Self::Error> {
491+
let store = self.store.open_exclusive(root_key)?;
492492
let store = LruCachingStore::new(store, self.storage_cache_config());
493493
store.enable_exclusive_access();
494494
Ok(store)

linera-views/src/backends/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl AdminKeyValueStore for MemoryStore {
321321
memory_stores.sync_connect(config, namespace, &[], kill_on_drop)
322322
}
323323

324-
fn clone_with_root_key(&self, root_key: &[u8]) -> Result<Self, MemoryStoreError> {
324+
fn open_exclusive(&self, root_key: &[u8]) -> Result<Self, MemoryStoreError> {
325325
let max_stream_queries = self.max_stream_queries;
326326
let common_config = CommonStoreInternalConfig {
327327
max_concurrent_queries: None,

0 commit comments

Comments
 (0)