@@ -3,7 +3,7 @@ use std::sync::Arc;
33use crate :: db:: model:: { MempoolInput , MempoolTx , Utxo } ;
44use crate :: db:: schema:: { mempool_inputs, mempool_tx, utxos} ;
55use crate :: indexer:: rpc:: BitcoinRpc ;
6- use chrono:: NaiveDateTime ;
6+ use chrono:: { NaiveDateTime , Utc } ;
77use diesel:: SqliteConnection ;
88use diesel:: prelude:: * ;
99use diesel:: r2d2:: ConnectionManager ;
@@ -30,7 +30,7 @@ impl<'a> Indexer<'a> {
3030
3131 for input in & tx. input {
3232 let prevout = & input. previous_output ;
33- diesel:: insert_into ( mempool_inputs:: table)
33+ diesel:: insert_or_ignore_into ( mempool_inputs:: table)
3434 . values ( & MempoolInput {
3535 txid : txid. to_string ( ) ,
3636 input_txid : prevout. txid . to_string ( ) ,
@@ -40,7 +40,7 @@ impl<'a> Indexer<'a> {
4040 . unwrap ( ) ;
4141
4242 self . mark_utxo_spent (
43- & txid. to_string ( ) ,
43+ & prevout . txid . to_string ( ) ,
4444 prevout. vout as i32 ,
4545 Some ( & txid. to_string ( ) ) ,
4646 false ,
@@ -106,7 +106,7 @@ impl<'a> Indexer<'a> {
106106 diesel:: insert_or_ignore_into ( mempool_tx:: table)
107107 . values ( & MempoolTx {
108108 txid : txid. to_string ( ) ,
109- seen_at : NaiveDateTime :: MIN ,
109+ seen_at : Utc :: now ( ) . naive_utc ( ) ,
110110 } )
111111 . execute ( & mut conn)
112112 . unwrap ( ) ;
0 commit comments