Skip to content

Commit

Permalink
Refactor inmemory (#263)
Browse files Browse the repository at this point in the history
* feat: remove check_conflicts from TemporaryStorage because it is not working

* refactor: simplify inmemory storages
  • Loading branch information
dinhani-cw authored Feb 22, 2024
1 parent a80f61c commit 4f5faaa
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 236 deletions.
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::eth::primitives::Address;
use crate::eth::primitives::BlockNumber;
use crate::eth::primitives::BlockSelection;
use crate::eth::primitives::StoragePointInTime;
use crate::eth::storage::InMemoryStoragePermanent;
use crate::eth::storage::InMemoryStorageTemporary;
use crate::eth::storage::InMemoryPermanentStorage;
use crate::eth::storage::InMemoryTemporaryStorage;
use crate::eth::storage::PermanentStorage;
use crate::eth::storage::StratusStorage;
use crate::eth::BlockMiner;
Expand Down Expand Up @@ -200,10 +200,10 @@ pub enum StorageConfig {
impl StorageConfig {
/// Initializes the storage implementation.
pub async fn init(&self) -> anyhow::Result<Arc<StratusStorage>> {
let temp = Arc::new(InMemoryStorageTemporary::default());
let temp = Arc::new(InMemoryTemporaryStorage::default());

let perm: Arc<dyn PermanentStorage> = match self {
Self::InMemory => Arc::new(InMemoryStoragePermanent::default()),
Self::InMemory => Arc::new(InMemoryPermanentStorage::default()),
Self::Postgres { url } => Arc::new(Postgres::new(url).await?),
};
Ok(Arc::new(StratusStorage::new(temp, perm)))
Expand Down
2 changes: 1 addition & 1 deletion src/eth/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl EthExecutor {
};

// temporarily save state to next transactions from the same block
self.storage.save_account_changes_to_temp(block.number(), execution.clone()).await?;
self.storage.save_account_changes_to_temp(execution.clone()).await?;
executions.push((tx, receipt, execution));
}
Err(e) => {
Expand Down
5 changes: 5 additions & 0 deletions src/eth/primitives/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ pub struct Account {
}

impl Account {
/// Creates a new empty account.
pub fn new_empty(address: Address) -> Self {
Self::new_with_balance(address, Wei::ZERO)
}

/// Creates a new account with initial balance.
pub fn new_with_balance(address: Address, balance: Wei) -> Self {
Self {
Expand Down
170 changes: 0 additions & 170 deletions src/eth/storage/inmemory/inmemory_account.rs

This file was deleted.

Loading

0 comments on commit 4f5faaa

Please sign in to comment.