Skip to content

Commit 8738581

Browse files
MartianGreedglihm
andauthored
fix(executor): fix timestamp diff on high tps (#19)
* fix(executor): fix timestamp diff on high tps * ensure no overflow could happen --------- Co-authored-by: glihm <dev@glihm.net>
1 parent 6d9aadd commit 8738581

File tree

1 file changed

+9
-1
lines changed
  • crates/sqlite/sqlite/src/executor

1 file changed

+9
-1
lines changed

crates/sqlite/sqlite/src/executor/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,15 @@ impl<P: Provider + Sync + Send + 'static> Executor<'_, P> {
403403
.unwrap()
404404
.as_secs();
405405

406-
num_transactions / (current_time - cursor_timestamp)
406+
let diff = current_time
407+
.checked_sub(cursor_timestamp)
408+
.unwrap_or_default();
409+
410+
if diff > 0 {
411+
num_transactions / diff
412+
} else {
413+
num_transactions
414+
}
407415
};
408416

409417
cursor.last_pending_block_contract_tx =

0 commit comments

Comments
 (0)