Skip to content

Commit

Permalink
perf: avoid recomputing tx_hash when saving execution (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw authored and marcospb19-cw committed Aug 13, 2024
1 parent 3f1eec5 commit a99da61
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit a99da61

Please sign in to comment.