Bring less data around

This commit is contained in:
Riccardo Casatta 2020-11-17 16:29:03 +01:00
parent 02c0ad2fca
commit 42480ea37b
No known key found for this signature in database
GPG Key ID: FD986A969E450397

View File

@ -308,7 +308,7 @@ fn save_transaction_details_and_utxos<D: BatchDatabase>(
timestamp: u64, timestamp: u64,
height: Option<u32>, height: Option<u32>,
updates: &mut dyn BatchOperations, updates: &mut dyn BatchOperations,
utxo_deps: &HashMap<OutPoint, UTXO>, utxo_deps: &HashMap<OutPoint, OutPoint>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let tx = db let tx = db
.get_raw_tx(txid)? .get_raw_tx(txid)?
@ -343,8 +343,8 @@ fn save_transaction_details_and_utxos<D: BatchDatabase>(
} }
// removes conflicting UTXO if any (generated from same inputs, like for example RBF) // removes conflicting UTXO if any (generated from same inputs, like for example RBF)
if let Some(utxo) = utxo_deps.get(&input.previous_output) { if let Some(outpoint) = utxo_deps.get(&input.previous_output) {
updates.del_utxo(&utxo.outpoint)?; updates.del_utxo(&outpoint)?;
} }
} }
@ -386,7 +386,7 @@ fn save_transaction_details_and_utxos<D: BatchDatabase>(
fn utxos_deps<D: BatchDatabase>( fn utxos_deps<D: BatchDatabase>(
db: &mut D, db: &mut D,
tx_raw_in_db: &HashMap<Txid, Transaction>, tx_raw_in_db: &HashMap<Txid, Transaction>,
) -> Result<HashMap<OutPoint, UTXO>, Error> { ) -> Result<HashMap<OutPoint, OutPoint>, Error> {
let utxos = db.iter_utxos()?; let utxos = db.iter_utxos()?;
let mut utxos_deps = HashMap::new(); let mut utxos_deps = HashMap::new();
for utxo in utxos { for utxo in utxos {
@ -394,7 +394,7 @@ fn utxos_deps<D: BatchDatabase>(
.get(&utxo.outpoint.txid) .get(&utxo.outpoint.txid)
.ok_or_else(|| Error::TransactionNotFound)?; .ok_or_else(|| Error::TransactionNotFound)?;
for input in from_tx.input.iter() { for input in from_tx.input.iter() {
utxos_deps.insert(input.previous_output, utxo.clone()); utxos_deps.insert(input.previous_output, utxo.outpoint);
} }
} }
Ok(utxos_deps) Ok(utxos_deps)