diff --git a/dbs-write-ops/src/txs_mp.rs b/dbs-write-ops/src/txs_mp.rs index 7f9e5139532553954fa592d61079721972a2bdd2..1058768e48c6ed9338ba7b339059836fd411e776 100644 --- a/dbs-write-ops/src/txs_mp.rs +++ b/dbs-write-ops/src/txs_mp.rs @@ -111,7 +111,13 @@ pub fn add_pending_tx< outputs_by_script.upsert(script, script_outputs); } // Insert tx itself - txs.upsert(HashKeyV2(tx_hash), PendingTxDbV2(tx.into_owned())); + txs.upsert( + HashKeyV2(tx_hash), + PendingTxDbV2 { + doc: tx.into_owned(), + received_time, + }, + ); Ok(()) }, ) @@ -177,7 +183,7 @@ fn remove_one_pending_tx<B: Backend>(txs_mp_db: &TxsMpV2Db<B>, tx_hash: Hash) -> mut outputs_by_script, )| { // Remove tx inputs in cols `uds_ids` and `utxos_ids` - for input in tx.0.get_inputs() { + for input in tx.doc.get_inputs() { match input.id { SourceIdV10::Ud(UdSourceIdV10 { issuer, @@ -191,14 +197,14 @@ fn remove_one_pending_tx<B: Backend>(txs_mp_db: &TxsMpV2Db<B>, tx_hash: Hash) -> } } // Remove tx hash in col `txs_by_issuer` - for pubkey in tx.0.issuers() { + for pubkey in tx.doc.issuers() { let mut hashs_ = txs_by_issuer.get(&PubKeyKeyV2(pubkey))?.unwrap_or_default(); hashs_.remove(&tx_hash); txs_by_issuer.upsert(PubKeyKeyV2(pubkey), hashs_) } // Remove tx hash in col `txs_by_recipient` - for pubkey in tx.0.recipients_keys() { + for pubkey in tx.doc.recipients_keys() { let mut hashs_ = txs_by_recipient .get(&PubKeyKeyV2(pubkey))? .unwrap_or_default(); @@ -206,7 +212,7 @@ fn remove_one_pending_tx<B: Backend>(txs_mp_db: &TxsMpV2Db<B>, tx_hash: Hash) -> txs_by_recipient.upsert(PubKeyKeyV2(pubkey), hashs_) } // Remove tx outputs in col `outputs` - for (output_index, output) in tx.0.get_outputs().iter().enumerate() { + for (output_index, output) in tx.doc.get_outputs().iter().enumerate() { let script = WalletConditionsV2(output.conditions.script.to_owned()); let utxo = UtxoValV2::new(output.amount, tx_hash, output_index as u32); let mut script_outputs = diff --git a/dbs/src/values/tx_db.rs b/dbs/src/values/tx_db.rs index bcc06d1499ff269ed83624dd2d2fcaacd2d031c0..59700b7509b24ee076cc2e8c0977d230c2e4734e 100644 --- a/dbs/src/values/tx_db.rs +++ b/dbs/src/values/tx_db.rs @@ -17,7 +17,10 @@ use crate::*; use dubp::documents::transaction::TransactionDocumentV10; #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] -pub struct PendingTxDbV2(pub TransactionDocumentV10); +pub struct PendingTxDbV2 { + pub doc: TransactionDocumentV10, + pub received_time: i64, +} impl AsBytes for PendingTxDbV2 { fn as_bytes<T, F: FnMut(&[u8]) -> T>(&self, mut f: F) -> T {