From 389c40201148140ca3ba5acce621044d9cd9742d Mon Sep 17 00:00:00 2001 From: barrystyle <14147070+barrystyle@users.noreply.github.com> Date: Fri, 22 Nov 2019 22:40:01 +0800 Subject: [PATCH] Revert vtx/cbtx positioning in stakeminer. (#32) --- src/miner.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f2427d5ce5491..27ba61c20782e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -171,26 +171,27 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc // Create coinbase transaction. CMutableTransaction coinbaseTx; - CMutableTransaction coinstakeTx; coinbaseTx.vin.resize(1); coinbaseTx.vin[0].prevout.SetNull(); coinbaseTx.vout.resize(1); coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn; CAmount blockReward = GetBlockSubsidy(pindexPrev->nHeight, Params().GetConsensus()); std::vector vwtxPrev; - bool fStakeFound = false; if(fProofOfStake) { assert(pwalletMain); boost::this_thread::interruption_point(); pblock->nBits = GetNextWorkRequired(pindexPrev, chainparams.GetConsensus()); + CMutableTransaction coinstakeTx; int64_t nSearchTime = pblock->nTime; // search to current time + bool fStakeFound = false; if (nSearchTime >= nLastCoinStakeSearchTime) { unsigned int nTxNewTime = 0; if (pwalletMain->CreateCoinStake(*pwalletMain, pblock->nBits, blockReward, coinstakeTx, nTxNewTime, vwtxPrev)) { pblock->nTime = nTxNewTime; coinbaseTx.vout[0].SetEmpty(); FillBlockPayments(coinstakeTx, nHeight, blockReward, pblocktemplate->voutMasternodePayments, pblocktemplate->voutSuperblockPayments); + pblock->vtx.emplace_back(MakeTransactionRef(coinstakeTx)); fStakeFound = true; } nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; @@ -253,14 +254,11 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc throw std::runtime_error(strprintf("%s: CalcCbTxMerkleRootQuorums failed: %s", __func__, FormatStateMessage(state))); } } + SetTxPayload(coinbaseTx, cbTx); } pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx)); - if (fStakeFound) { - pblock->vtx.resize(pblock->vtx.size() + 1); - pblock->vtx[1] = MakeTransactionRef(std::move(coinstakeTx)); - } pblocktemplate->vTxFees[0] = -nFees; // Fill in header