From 987a66e0e7e0d5fc5cafa1deb652ebcbc101fbd3 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Tue, 20 Aug 2024 14:31:13 +0200 Subject: [PATCH] Avoid recomputing txid in TxRow add_blocks time: [2.9788 ms 2.9938 ms 3.0101 ms] change: [-24.810% -24.373% -23.897%] (p = 0.00 < 0.05) Performance has improved. --- src/new_index/schema.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/new_index/schema.rs b/src/new_index/schema.rs index e0bc2c7e6..1ea2a97ef 100644 --- a/src/new_index/schema.rs +++ b/src/new_index/schema.rs @@ -1005,7 +1005,7 @@ fn add_transaction( rows.push(TxConfRow::new(txid, blockhash).into_row()); if !iconfig.light_mode { - rows.push(TxRow::new(tx).into_row()); + rows.push(TxRow::new(txid, tx).into_row()); } let txid = full_hash(&txid[..]); @@ -1183,8 +1183,8 @@ struct TxRow { } impl TxRow { - fn new(txn: &Transaction) -> TxRow { - let txid = full_hash(&txn.txid()[..]); + fn new(txid: Txid, txn: &Transaction) -> TxRow { + let txid = full_hash(&txid[..]); TxRow { key: TxRowKey { code: b'T', txid }, value: serialize(txn),