Browse Source

Exclude witness transactions in addPackageTxs() pre-segwit activation

0.13
Suhas Daftuar 9 years ago
parent
commit
6dd4bc289c
  1. 13
      src/miner.cpp
  2. 7
      src/miner.h

13
src/miner.cpp

@ -236,14 +236,19 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
return true; return true;
} }
// Block size and sigops have already been tested. Check that all transactions // Perform transaction-level checks before adding to block:
// are final. // - transaction finality (locktime)
bool BlockAssembler::TestPackageFinalityAndSerializedSize(const CTxMemPool::setEntries& package) // - 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 uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
BOOST_FOREACH (const CTxMemPool::txiter it, package) { BOOST_FOREACH (const CTxMemPool::txiter it, package) {
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
return false; return false;
if (!fIncludeWitness && !it->GetTx().wit.IsNull())
return false;
if (fNeedSizeAccounting) { if (fNeedSizeAccounting) {
uint64_t nTxSize = ::GetSerializeSize(it->GetTx(), SER_NETWORK, PROTOCOL_VERSION); uint64_t nTxSize = ::GetSerializeSize(it->GetTx(), SER_NETWORK, PROTOCOL_VERSION);
if (nPotentialBlockSize + nTxSize >= nBlockMaxSize) { if (nPotentialBlockSize + nTxSize >= nBlockMaxSize) {
@ -542,7 +547,7 @@ void BlockAssembler::addPackageTxs()
ancestors.insert(iter); ancestors.insert(iter);
// Test if all tx's are Final // Test if all tx's are Final
if (!TestPackageFinalityAndSerializedSize(ancestors)) { if (!TestPackageTransactions(ancestors)) {
if (fUsingModified) { if (fUsingModified) {
mapModifiedTx.get<ancestor_score>().erase(modit); mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter); failedTx.insert(iter);

7
src/miner.h

@ -192,8 +192,11 @@ private:
void onlyUnconfirmed(CTxMemPool::setEntries& testSet); void onlyUnconfirmed(CTxMemPool::setEntries& testSet);
/** Test if a new package would "fit" in the block */ /** Test if a new package would "fit" in the block */
bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost); bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost);
/** Test if a set of transactions are all final */ /** Perform checks on each transaction in a package:
bool TestPackageFinalityAndSerializedSize(const CTxMemPool::setEntries& 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, /** Return true if given transaction from mapTx has already been evaluated,
* or if the transaction's cached data in mapTx is incorrect. */ * or if the transaction's cached data in mapTx is incorrect. */
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx); bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx);

Loading…
Cancel
Save