aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2016-06-30 11:22:31 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2016-06-30 11:24:32 -0400
commit6dd4bc289c71f622ac561f6f9651546b9ec4fa3e (patch)
tree52ba0383e80b30d7c0f1590f8f4d301929c64cf6
parentf15c2cde455174c7c899833fd5792460ed49a472 (diff)
Exclude witness transactions in addPackageTxs() pre-segwit activation
-rw-r--r--src/miner.cpp13
-rw-r--r--src/miner.h7
2 files changed, 14 insertions, 6 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index a3e29431d7..f2ad1018b2 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -236,14 +236,19 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
return true;
}
-// Block size and sigops have already been tested. Check that all transactions
-// are final.
-bool BlockAssembler::TestPackageFinalityAndSerializedSize(const CTxMemPool::setEntries& package)
+// Perform transaction-level checks before adding to block:
+// - transaction finality (locktime)
+// - premature witness (in case segwit transactions are added to mempool before
+// segwit activation)
+// - serialized size (in case -blockmaxsize is in use)
+bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
{
uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
return false;
+ if (!fIncludeWitness && !it->GetTx().wit.IsNull())
+ return false;
if (fNeedSizeAccounting) {
uint64_t nTxSize = ::GetSerializeSize(it->GetTx(), SER_NETWORK, PROTOCOL_VERSION);
if (nPotentialBlockSize + nTxSize >= nBlockMaxSize) {
@@ -542,7 +547,7 @@ void BlockAssembler::addPackageTxs()
ancestors.insert(iter);
// Test if all tx's are Final
- if (!TestPackageFinalityAndSerializedSize(ancestors)) {
+ if (!TestPackageTransactions(ancestors)) {
if (fUsingModified) {
mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter);
diff --git a/src/miner.h b/src/miner.h
index bc4da63da0..9fab55611e 100644
--- a/src/miner.h
+++ b/src/miner.h
@@ -192,8 +192,11 @@ private:
void onlyUnconfirmed(CTxMemPool::setEntries& testSet);
/** Test if a new package would "fit" in the block */
bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost);
- /** Test if a set of transactions are all final */
- bool TestPackageFinalityAndSerializedSize(const CTxMemPool::setEntries& package);
+ /** Perform checks on each transaction in a package:
+ * locktime, premature-witness, serialized size (if necessary)
+ * These checks should always succeed, and they're here
+ * only as an extra check in case of suboptimal node configuration */
+ bool TestPackageTransactions(const CTxMemPool::setEntries& package);
/** Return true if given transaction from mapTx has already been evaluated,
* or if the transaction's cached data in mapTx is incorrect. */
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx);