Skip to content

Commit

Permalink
feat: implementing read_slots for rocks and inmemory by delegating to…
Browse files Browse the repository at this point in the history
… read_slot (#574)
  • Loading branch information
dinhani-cw authored Apr 12, 2024
1 parent 0332dac commit 10db006
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
19 changes: 12 additions & 7 deletions src/eth/storage/inmemory/inmemory_permanent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,18 @@ impl PermanentStorage for InMemoryPermanentStorage {
}
}

async fn read_slots(
&self,
_address: &Address,
_indexes: &[SlotIndex],
_point_in_time: &StoragePointInTime,
) -> anyhow::Result<HashMap<SlotIndex, SlotValue>> {
todo!()
async fn read_slots(&self, address: &Address, indexes: &[SlotIndex], point_in_time: &StoragePointInTime) -> anyhow::Result<HashMap<SlotIndex, SlotValue>> {
tracing::debug!(%address, indexes_len = %indexes.len(), "reading slots");

let mut slots = HashMap::with_capacity(indexes.len());
for index in indexes {
let slot = self.read_slot(address, index, point_in_time).await?;
if let Some(slot) = slot {
slots.insert(slot.index, slot.value);
}
}

Ok(slots)
}

async fn read_block(&self, selection: &BlockSelection) -> anyhow::Result<Option<Block>> {
Expand Down
19 changes: 12 additions & 7 deletions src/eth/storage/rocks/rocks_permanent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,18 @@ impl PermanentStorage for RocksPermanentStorage {
Ok(self.state.read_slot(address, index, point_in_time))
}

async fn read_slots(
&self,
_address: &Address,
_indexes: &[SlotIndex],
_point_in_time: &StoragePointInTime,
) -> anyhow::Result<HashMap<SlotIndex, SlotValue>> {
todo!()
async fn read_slots(&self, address: &Address, indexes: &[SlotIndex], point_in_time: &StoragePointInTime) -> anyhow::Result<HashMap<SlotIndex, SlotValue>> {
tracing::debug!(%address, indexes_len = %indexes.len(), "reading slots");

let mut slots = HashMap::with_capacity(indexes.len());
for index in indexes {
let slot = self.read_slot(address, index, point_in_time).await?;
if let Some(slot) = slot {
slots.insert(slot.index, slot.value);
}
}

Ok(slots)
}

async fn read_block(&self, selection: &BlockSelection) -> anyhow::Result<Option<Block>> {
Expand Down

0 comments on commit 10db006

Please sign in to comment.