From 2f0c6d3e2560b5701e65db751912f7138eaffda8 Mon Sep 17 00:00:00 2001 From: Renato Dinhani <101204870+dinhani-cw@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:57:03 -0300 Subject: [PATCH] refactor: reorder InMemoryTemporaryStorage methods to match trait order (#1238) --- .../storage/inmemory/inmemory_temporary.rs | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/eth/storage/inmemory/inmemory_temporary.rs b/src/eth/storage/inmemory/inmemory_temporary.rs index 6a3a6c05e..84ffdf12e 100644 --- a/src/eth/storage/inmemory/inmemory_temporary.rs +++ b/src/eth/storage/inmemory/inmemory_temporary.rs @@ -113,20 +113,6 @@ impl InMemoryTemporaryAccount { } impl TemporaryStorage for InMemoryTemporaryStorage { - // ------------------------------------------------------------------------- - // Accounts and Slots - // ------------------------------------------------------------------------- - - fn read_account(&self, address: &Address) -> anyhow::Result> { - let states = self.lock_read(); - Ok(read_account(&states, address)) - } - - fn read_slot(&self, address: &Address, index: &SlotIndex) -> anyhow::Result> { - let states = self.lock_read(); - Ok(read_slot(&states, address, index)) - } - // ------------------------------------------------------------------------- // Block number // ------------------------------------------------------------------------- @@ -151,7 +137,7 @@ impl TemporaryStorage for InMemoryTemporaryStorage { } // ------------------------------------------------------------------------- - // External block + // Block and executions // ------------------------------------------------------------------------- fn set_active_external_block(&self, block: ExternalBlock) -> anyhow::Result<()> { @@ -160,10 +146,6 @@ impl TemporaryStorage for InMemoryTemporaryStorage { Ok(()) } - // ------------------------------------------------------------------------- - // Executions - // ------------------------------------------------------------------------- - fn save_execution(&self, tx: TransactionExecution) -> anyhow::Result<()> { // check conflicts let mut states = self.lock_write(); @@ -207,15 +189,6 @@ impl TemporaryStorage for InMemoryTemporaryStorage { Ok(()) } - // ------------------------------------------------------------------------- - // General state - // ------------------------------------------------------------------------- - - fn check_conflicts(&self, execution: &EvmExecution) -> anyhow::Result> { - let states = self.lock_read(); - Ok(check_conflicts(&states, execution)) - } - /// TODO: we cannot allow more than one pending block. Where to put this check? fn finish_block(&self) -> anyhow::Result { let mut states = self.lock_write(); @@ -233,6 +206,28 @@ impl TemporaryStorage for InMemoryTemporaryStorage { Ok(finished_block) } + // ------------------------------------------------------------------------- + // Accounts and Slots + // ------------------------------------------------------------------------- + + fn check_conflicts(&self, execution: &EvmExecution) -> anyhow::Result> { + let states = self.lock_read(); + Ok(check_conflicts(&states, execution)) + } + + fn read_account(&self, address: &Address) -> anyhow::Result> { + let states = self.lock_read(); + Ok(read_account(&states, address)) + } + + fn read_slot(&self, address: &Address, index: &SlotIndex) -> anyhow::Result> { + let states = self.lock_read(); + Ok(read_slot(&states, address, index)) + } + + // ------------------------------------------------------------------------- + // Global state + // ------------------------------------------------------------------------- fn reset(&self) -> anyhow::Result<()> { let mut state = self.lock_write(); state.tail.clear();