Skip to content

Commit 2f0c6d3

Browse files
authored
refactor: reorder InMemoryTemporaryStorage methods to match trait order (#1238)
1 parent 161e710 commit 2f0c6d3

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

src/eth/storage/inmemory/inmemory_temporary.rs

+23-28
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,6 @@ impl InMemoryTemporaryAccount {
113113
}
114114

115115
impl TemporaryStorage for InMemoryTemporaryStorage {
116-
// -------------------------------------------------------------------------
117-
// Accounts and Slots
118-
// -------------------------------------------------------------------------
119-
120-
fn read_account(&self, address: &Address) -> anyhow::Result<Option<Account>> {
121-
let states = self.lock_read();
122-
Ok(read_account(&states, address))
123-
}
124-
125-
fn read_slot(&self, address: &Address, index: &SlotIndex) -> anyhow::Result<Option<Slot>> {
126-
let states = self.lock_read();
127-
Ok(read_slot(&states, address, index))
128-
}
129-
130116
// -------------------------------------------------------------------------
131117
// Block number
132118
// -------------------------------------------------------------------------
@@ -151,7 +137,7 @@ impl TemporaryStorage for InMemoryTemporaryStorage {
151137
}
152138

153139
// -------------------------------------------------------------------------
154-
// External block
140+
// Block and executions
155141
// -------------------------------------------------------------------------
156142

157143
fn set_active_external_block(&self, block: ExternalBlock) -> anyhow::Result<()> {
@@ -160,10 +146,6 @@ impl TemporaryStorage for InMemoryTemporaryStorage {
160146
Ok(())
161147
}
162148

163-
// -------------------------------------------------------------------------
164-
// Executions
165-
// -------------------------------------------------------------------------
166-
167149
fn save_execution(&self, tx: TransactionExecution) -> anyhow::Result<()> {
168150
// check conflicts
169151
let mut states = self.lock_write();
@@ -207,15 +189,6 @@ impl TemporaryStorage for InMemoryTemporaryStorage {
207189
Ok(())
208190
}
209191

210-
// -------------------------------------------------------------------------
211-
// General state
212-
// -------------------------------------------------------------------------
213-
214-
fn check_conflicts(&self, execution: &EvmExecution) -> anyhow::Result<Option<ExecutionConflicts>> {
215-
let states = self.lock_read();
216-
Ok(check_conflicts(&states, execution))
217-
}
218-
219192
/// TODO: we cannot allow more than one pending block. Where to put this check?
220193
fn finish_block(&self) -> anyhow::Result<PendingBlock> {
221194
let mut states = self.lock_write();
@@ -233,6 +206,28 @@ impl TemporaryStorage for InMemoryTemporaryStorage {
233206
Ok(finished_block)
234207
}
235208

209+
// -------------------------------------------------------------------------
210+
// Accounts and Slots
211+
// -------------------------------------------------------------------------
212+
213+
fn check_conflicts(&self, execution: &EvmExecution) -> anyhow::Result<Option<ExecutionConflicts>> {
214+
let states = self.lock_read();
215+
Ok(check_conflicts(&states, execution))
216+
}
217+
218+
fn read_account(&self, address: &Address) -> anyhow::Result<Option<Account>> {
219+
let states = self.lock_read();
220+
Ok(read_account(&states, address))
221+
}
222+
223+
fn read_slot(&self, address: &Address, index: &SlotIndex) -> anyhow::Result<Option<Slot>> {
224+
let states = self.lock_read();
225+
Ok(read_slot(&states, address, index))
226+
}
227+
228+
// -------------------------------------------------------------------------
229+
// Global state
230+
// -------------------------------------------------------------------------
236231
fn reset(&self) -> anyhow::Result<()> {
237232
let mut state = self.lock_write();
238233
state.tail.clear();

0 commit comments

Comments
 (0)