Simplify tx.validate() and transaction::aggregate() (#1436)

* simplify tx validation and aggregation
we *only* need to account for reward when building a block from txs

* rustfmt

* cleanup and tests passing

* rustfmt

* better comments in with_reward()

* fix wallet tests
This commit is contained in:
Antioch Peverell
2018-08-28 20:00:25 +01:00
committed by GitHub
parent 3dacc6a397
commit c334c557aa
10 changed files with 120 additions and 135 deletions
+3 -3
View File
@@ -86,7 +86,7 @@ impl Pool {
.into_iter()
.filter_map(|mut bucket| {
bucket.truncate(MAX_TX_CHAIN);
transaction::aggregate(bucket, None).ok()
transaction::aggregate(bucket).ok()
})
.collect();
@@ -118,7 +118,7 @@ impl Pool {
return Ok(None);
}
let tx = transaction::aggregate(txs, None)?;
let tx = transaction::aggregate(txs)?;
Ok(Some(tx))
}
@@ -191,7 +191,7 @@ impl Pool {
// Create a single aggregated tx from the existing pool txs and the
// new entry
txs.push(entry.tx.clone());
transaction::aggregate(txs, None)?
transaction::aggregate(txs)?
};
// Validate aggregated tx against a known chain state (via txhashset
+1 -1
View File
@@ -100,7 +100,7 @@ impl TransactionPool {
self.is_acceptable(&tx)?;
// Make sure the transaction is valid before anything else.
tx.validate(false).map_err(|e| PoolError::InvalidTx(e))?;
tx.validate().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)?;
+1 -1
View File
@@ -219,7 +219,7 @@ fn test_the_transaction_pool() {
let tx4 = test_transaction(&keychain, vec![800], vec![799]);
// tx1 and tx2 are already in the txpool (in aggregated form)
// tx4 is the "new" part of this aggregated tx that we care about
let agg_tx = transaction::aggregate(vec![tx1.clone(), tx2.clone(), tx4], None).unwrap();
let agg_tx = transaction::aggregate(vec![tx1.clone(), tx2.clone(), tx4]).unwrap();
write_pool
.add_to_pool(test_source(), agg_tx, false, &header.hash())
.unwrap();