@@ -1322,9 +1322,7 @@ impl LMDBDatabase {
13221322 txn : & WriteTransaction < ' _ > ,
13231323 header : & BlockHeader ,
13241324 body : AggregateBody ,
1325- // smt_writer: &mut LmdbTreeWriter,
13261325 ) -> Result < ( ) , ChainStorageError > {
1327- // let smt_reader = LmdbTreeReader::new();
13281326 let smt_reader = LmdbTreeReader :: new ( txn, self . jmt_node_data . clone ( ) , self . jmt_unique_key_data . clone ( ) ) ;
13291327 let output_smt = JellyfishMerkleTree :: < _ , SmtHasher > :: new ( & smt_reader) ;
13301328 if self . fetch_block_accumulated_data ( txn, header. height + 1 ) ?. is_some ( ) {
@@ -3269,12 +3267,21 @@ fn process_payref_for_height(db: &LMDBDatabase, height: u64) -> Result<(), Chain
32693267 // Get all outputs for this block
32703268 let outputs: Vec < ( Vec < u8 > , TransactionOutputRowData ) > =
32713269 lmdb_fetch_matching_after ( & read_txn, & db. utxos_db , block_hash. as_slice ( ) ) ?;
3272-
3270+ let mut payrefs = Vec :: new ( ) ;
3271+ for ( _, output_data) in outputs {
3272+ let exist = lmdb_exists (
3273+ & read_txn,
3274+ & db. utxo_commitment_index ,
3275+ output_data. output . commitment ( ) . as_bytes ( ) ,
3276+ ) ?;
3277+ if exist {
3278+ let payref = LMDBDatabase :: generate_payment_reference_for_output ( & block_hash, & output_data. hash ) ;
3279+ payrefs. push ( ( payref, output_data. hash ) ) ;
3280+ }
3281+ }
32733282 drop ( read_txn) ;
32743283 let write_txn = db. write_transaction ( ) ?;
3275- for ( _, output_data) in outputs {
3276- let output_hash = & output_data. hash ;
3277- let payref = LMDBDatabase :: generate_payment_reference_for_output ( & block_hash, output_hash) ;
3284+ for ( payref, output_hash) in payrefs {
32783285 lmdb_insert (
32793286 & write_txn,
32803287 & db. payref_to_output_index ,
0 commit comments