Skip to content

Commit 3d49725

Browse files
authored
Create key space for block exporters (#3729)
## Motivation Help with #3665 ## Proposal * Create a key prefix for block exporters (each identified by a `u32`) * Create a method `block_exporter_context` in `linera_storage::DbStorage` ## Test Plan CI
1 parent 38c3198 commit 3d49725

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

linera-storage/src/db_storage.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ enum BaseKey {
275275
Blob(BlobId),
276276
BlobState(BlobId),
277277
Event(EventId),
278+
BlockExporterState(u32),
278279
}
279280

280281
const INDEX_CHAIN_ID: u8 = 0;
@@ -904,6 +905,15 @@ where
904905
let store = Store::connect(&config, namespace).await?;
905906
Ok(Self::create(store, wasm_runtime, WallClock))
906907
}
908+
909+
pub async fn block_exporter_context(
910+
&self,
911+
block_exporter_id: u32,
912+
) -> Result<ViewContext<u32, Store>, ViewError> {
913+
let root_key = bcs::to_bytes(&BaseKey::BlockExporterState(block_exporter_id))?;
914+
let store = self.store.clone_with_root_key(&root_key)?;
915+
Ok(ViewContext::create_root_context(store, block_exporter_id).await?)
916+
}
907917
}
908918

909919
#[cfg(with_testing)]

0 commit comments

Comments
 (0)