[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add static file helpers on StorageWriter #9740

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
rename log_transactions to write_transactions
  • Loading branch information
Rjected committed Jul 23, 2024
commit 20c5399d86d09306224925c68532a5bda5282aa5
12 changes: 6 additions & 6 deletions crates/engine/tree/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ impl<DB: Database> PersistenceService<DB> {
Ok(())
}

/// Writes the transactions to static files, to act as a log.
/// Writes the transactions to static files.
///
/// The [`update_transaction_meta`](Self::update_transaction_meta) method should be called
/// after this, to update the checkpoints for headers and block bodies.
fn log_transactions(&self, block: Arc<SealedBlock>) -> ProviderResult<u64> {
debug!(target: "tree::persistence", "Logging transactions");
fn write_transactions(&self, block: Arc<SealedBlock>) -> ProviderResult<u64> {
debug!(target: "tree::persistence", "Writing transactions");
let provider = self.provider.static_file_provider();

let header_writer = provider.get_writer(block.number, StaticFileSegment::Headers)?;
Expand Down Expand Up @@ -280,8 +280,8 @@ where
// we ignore the error because the caller may or may not care about the result
let _ = sender.send(res);
}
PersistenceAction::LogTransactions((block, sender)) => {
let block_num = self.log_transactions(block).expect("todo: handle errors");
PersistenceAction::WriteTransactions((block, sender)) => {
let block_num = self.write_transactions(block).expect("todo: handle errors");
self.update_transaction_meta(block_num).expect("todo: handle errors");

// we ignore the error because the caller may or may not care about the result
Expand All @@ -307,7 +307,7 @@ pub enum PersistenceAction {
///
/// This will first append the header and transactions to static files, then update the
/// checkpoints for headers and block bodies in the database.
LogTransactions((Arc<SealedBlock>, oneshot::Sender<()>)),
WriteTransactions((Arc<SealedBlock>, oneshot::Sender<()>)),

/// Removes block data above the given block number from the database.
///
Expand Down
2 changes: 0 additions & 2 deletions crates/storage/provider/src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ impl<'a, 'b, DB: Database> StorageWriter<'a, 'b, DB> {
first_tx_index = Some(0);
}

// TODO: I guess this error will never be returned
let mut tx_index = first_tx_index
.or(last_tx_idx)
.ok_or_else(|| ProviderError::BlockBodyIndicesNotFound(block_number))?;
Expand Down Expand Up @@ -284,7 +283,6 @@ impl<'a, 'b, DB: Database> StorageWriter<'a, 'b, DB> {
first_tx_index = Some(0);
}

// TODO: I guess this error will never be returned
let first_tx_index = first_tx_index
.or(last_tx_idx)
.ok_or_else(|| ProviderError::BlockBodyIndicesNotFound(block_number))?;
Expand Down
Loading