track tx seq number time consumed (#268)
Some checks are pending
abi-consistent-check / build-and-compare (push) Waiting to run
code-coverage / unittest-cov (push) Waiting to run
rust / check (push) Waiting to run
rust / test (push) Waiting to run
rust / lints (push) Waiting to run
functional-test / test (push) Waiting to run

This commit is contained in:
0g-peterzhb 2024-11-14 16:54:42 +08:00 committed by GitHub
parent 1046fed088
commit 4b48d25fb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -38,4 +38,6 @@ lazy_static::lazy_static! {
pub static ref FINALIZE_TX_WITH_HASH: Arc<dyn Timer> = register_timer("log_store_log_manager_finalize_tx_with_hash");
pub static ref DATA_TO_MERKLE_LEAVES_SIZE: Arc<dyn Gauge<usize>> = GaugeUsize::register("log_store_data_to_merkle_leaves_size");
pub static ref TX_BY_SEQ_NUMBER: Arc<dyn Timer> = register_timer("log_store_tx_store_get_tx_by_seq_number");
}

View File

@ -118,11 +118,13 @@ impl TransactionStore {
}
pub fn get_tx_by_seq_number(&self, seq: u64) -> Result<Option<Transaction>> {
let start_time = Instant::now();
if seq >= self.next_tx_seq() {
return Ok(None);
}
let value = try_option!(self.kvdb.get(COL_TX, &seq.to_be_bytes())?);
let tx = Transaction::from_ssz_bytes(&value).map_err(Error::from)?;
metrics::TX_BY_SEQ_NUMBER.update_since(start_time);
Ok(Some(tx))
}