diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2016-08-08 21:16:40 +0000 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-08-10 14:59:29 +0200 |
commit | 8b0eee66e9c9057b6e53bb1f4a0a3821083e5df0 (patch) | |
tree | 3266b60a17bf5325de49a39ee31540cf54af62b2 /src | |
parent | 45c656b914f0bbc0b087f21f438b1a792bd9d38d (diff) |
Bugfix: Use pre-BIP141 sigops until segwit activates
qa/rpc-tests/segwit: Test GBT sigops before and after activation
Github-Pull: #8489
Rebased-From: 160f895a80660e4e3904a2624e4110960d051902 239cbd2e5c2a36843b45b356e9aea6e8d35f0968
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/mining.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 92ca4bab6b..2479e5d595 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -546,6 +546,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) UpdateTime(pblock, consensusParams, pindexPrev); pblock->nNonce = 0; + // NOTE: If at some point we support pre-segwit miners post-segwit-activation, this needs to take segwit support into consideration + const bool fPreSegWit = (THRESHOLD_ACTIVE != VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT, versionbitscache)); + UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal"); UniValue transactions(UniValue::VARR); @@ -574,7 +577,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) int index_in_template = i - 1; entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); - entry.push_back(Pair("sigops", pblocktemplate->vTxSigOpsCost[index_in_template])); + int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template]; + if (fPreSegWit) { + assert(nTxSigOps % WITNESS_SCALE_FACTOR == 0); + nTxSigOps /= WITNESS_SCALE_FACTOR; + } + entry.push_back(Pair("sigops", nTxSigOps)); entry.push_back(Pair("weight", GetTransactionWeight(tx))); transactions.push_back(entry); @@ -657,7 +665,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1)); result.push_back(Pair("mutable", aMutable)); result.push_back(Pair("noncerange", "00000000ffffffff")); - result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS_COST)); + int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST; + if (fPreSegWit) { + assert(nSigOpLimit % WITNESS_SCALE_FACTOR == 0); + nSigOpLimit /= WITNESS_SCALE_FACTOR; + } + result.push_back(Pair("sigoplimit", nSigOpLimit)); result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SERIALIZED_SIZE)); result.push_back(Pair("weightlimit", (int64_t)MAX_BLOCK_WEIGHT)); result.push_back(Pair("curtime", pblock->GetBlockTime())); |