Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions crates/optimism/trie/src/backfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ async fn backfill<
Ok(total_entries)
}

/// Save address mappings to storage.
async fn save_address_mappings<S: OpProofsStore>(
storage: &S,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming it's not possible to have this be a method that takes &self instead of storage?

entries: Vec<(B256, Address)>,
) -> Result<(), OpProofsStorageError> {
storage.store_address_mappings(entries).await?;
Ok(())
}

impl<'a, Tx: DbTx, S: OpProofsStore + Send> BackfillJob<'a, Tx, S> {
/// Create a new backfill job.
pub const fn new(storage: S, tx: &'a Tx) -> Self {
Expand Down Expand Up @@ -274,17 +283,12 @@ impl<'a, Tx: DbTx, S: OpProofsStore + Send> BackfillJob<'a, Tx, S> {
let source = AddressLookupIter::new(start_cursor)
.map(|res| res.map(|(addr, _)| (keccak256(addr), addr)));
let storage = &self.storage;
let save_fn = async |entries: Vec<(B256, Address)>| -> Result<(), OpProofsStorageError> {
storage.store_address_mappings(entries).await?;
Ok(())
};

backfill(
"address mappings",
source,
BACKFILL_STORAGE_THRESHOLD,
BACKFILL_LOG_THRESHOLD,
save_fn,
|entries| save_address_mappings(storage, entries),
)
.await?;

Expand Down
Loading