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

perf: avoid recomputing tx_hash when saving execution #1634

Merged
merged 2 commits into from
Aug 12, 2024
Merged
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
9 changes: 6 additions & 3 deletions src/eth/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ impl Miner {

/// Persists a transaction execution.
pub fn save_execution(&self, tx_execution: TransactionExecution, check_conflicts: bool) -> Result<(), StratusError> {
let tx_hash = tx_execution.hash();

// track
#[cfg(feature = "tracing")]
let _span = info_span!("miner::save_execution", tx_hash = %tx_execution.hash()).entered();
let _span = info_span!("miner::save_execution", %tx_hash).entered();

// if automine is enabled, only one transaction can enter the block at time.
let _save_execution_lock = if self.mode.is_automine() {
Expand All @@ -106,11 +108,12 @@ impl Miner {
};

// save execution to temporary storage
let tx_hash = tx_execution.hash();
self.storage.save_execution(tx_execution, check_conflicts)?;

// if automine is enabled, automatically mines a block
// notify
let _ = self.notifier_pending_txs.send(tx_hash);

// if automine is enabled, automatically mines a block
if self.mode.is_automine() {
self.mine_local_and_commit()?;
}
Expand Down