Skip to content

Commit

Permalink
Avoid recomputing txid in TxRow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RCasatta committed Aug 20, 2024
1 parent 4e7831b commit 987a66e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/new_index/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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[..]);
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 987a66e

Please sign in to comment.