Skip to content

Commit

Permalink
feat: rocks temporary storage (mimicking sled's implementation) (#562)
Browse files Browse the repository at this point in the history
* feat: rocks temporary storage (mimicking sled's implementation)

* fmt
  • Loading branch information
carneiro-cw authored Apr 10, 2024
1 parent 9c12bd1 commit f75ece6
Show file tree
Hide file tree
Showing 8 changed files with 789 additions and 606 deletions.
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use crate::eth::storage::PostgresExternalRpcStorageConfig;
use crate::eth::storage::PostgresPermanentStorage;
use crate::eth::storage::PostgresPermanentStorageConfig;
use crate::eth::storage::RocksPermanentStorage;
use crate::eth::storage::RocksTemporary;
use crate::eth::storage::SledTemporary;
use crate::eth::storage::StratusStorage;
use crate::eth::storage::TemporaryStorage;
Expand Down Expand Up @@ -546,6 +547,7 @@ pub struct TemporaryStorageConfig {
pub enum TemporaryStorageKind {
InMemory,
Sled,
Rocks,
}

impl TemporaryStorageConfig {
Expand All @@ -554,6 +556,7 @@ impl TemporaryStorageConfig {
match self.temp_storage_kind {
TemporaryStorageKind::InMemory => Ok(Arc::new(InMemoryTemporaryStorage::default())),
TemporaryStorageKind::Sled => Ok(Arc::new(SledTemporary::new()?)),
TemporaryStorageKind::Rocks => Ok(Arc::new(RocksTemporary::new()?)),
}
}
}
Expand All @@ -565,6 +568,7 @@ impl FromStr for TemporaryStorageKind {
match s {
"inmemory" => Ok(Self::InMemory),
"sled" => Ok(Self::Sled),
"rocks" => Ok(Self::Rocks),
s => Err(anyhow!("unknown temporary storage: {}", s)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/eth/storage/inmemory/inmemory_temporary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl TemporaryStorage for InMemoryTemporaryStorage {
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct InMemoryTemporaryAccount {
pub info: Account,
pub slots: HashMap<SlotIndex, Slot>,
Expand Down
3 changes: 2 additions & 1 deletion src/eth/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub use postgres_external_rpc::PostgresExternalRpcStorage;
pub use postgres_external_rpc::PostgresExternalRpcStorageConfig;
pub use postgres_permanent::PostgresPermanentStorage;
pub use postgres_permanent::PostgresPermanentStorageConfig;
pub use rocks::RocksPermanentStorage;
pub use rocks::rocks_permanent::RocksPermanentStorage;
pub use rocks::rocks_temporary::RocksTemporary;
pub use sled::SledTemporary;
pub use storage_error::StorageError;
pub use stratus_storage::StratusStorage;
Expand Down
Loading

0 comments on commit f75ece6

Please sign in to comment.