Consolidate and cleanup tx aggregation (#1332)

* Include commitments non-duplicate checks in aggregate
* Remove said check from the pool
* Block building now uses tx aggregation to reduce duplication
This commit is contained in:
Ignotus Peverell
2018-08-12 19:08:08 -07:00
committed by GitHub
parent 4be97abbbb
commit e9c987c075
12 changed files with 149 additions and 191 deletions
+5 -15
View File
@@ -87,7 +87,7 @@ where
return Ok(None);
}
let tx = transaction::aggregate(txs)?;
let tx = transaction::aggregate(txs, None)?;
Ok(Some(tx))
}
@@ -142,20 +142,10 @@ where
// If we have nothing to aggregate then simply return the tx itself.
entry.tx.clone()
} else {
// Create a single aggregated tx from the existing pool txs (to check pool is
// valid).
let agg_tx = transaction::aggregate(txs)?;
// Then check new tx would not introduce a duplicate output in the pool.
for x in &entry.tx.outputs {
if agg_tx.outputs.contains(&x) {
return Err(PoolError::DuplicateCommitment);
}
}
// Finally aggregate the new tx with everything in the pool (with any extra
// txs).
transaction::aggregate(vec![agg_tx, entry.tx.clone()])?
// Create a single aggregated tx from the existing pool txs and the
// new entry
txs.push(entry.tx.clone());
transaction::aggregate(txs, None)?
};
// Validate aggregated tx against the current chain state (via txhashset
+1 -1
View File
@@ -108,7 +108,7 @@ where
self.is_acceptable(&tx)?;
// Make sure the transaction is valid before anything else.
tx.validate().map_err(|e| PoolError::InvalidTx(e))?;
tx.validate(false).map_err(|e| PoolError::InvalidTx(e))?;
// Check the tx lock_time is valid based on current chain state.
self.blockchain.verify_tx_lock_height(&tx)?;