From 96435288fa6792f70b55dc248464a267c5f1b776 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sat, 28 Jul 2018 16:51:29 +0300 Subject: [PATCH] Move block template specific stuff from CBlock to CBlockTemplate (#2195) --- src/miner.cpp | 4 ++-- src/miner.h | 2 ++ src/primitives/block.h | 4 ---- src/rpc/mining.cpp | 12 ++++++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fcb03eae3..0290dedbc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -170,9 +170,9 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc // Update coinbase transaction with additional info about masternode and governance payments, // get some info back to pass to getblocktemplate - FillBlockPayments(coinbaseTx, nHeight, blockReward, pblock->txoutMasternode, pblock->voutSuperblock); + FillBlockPayments(coinbaseTx, nHeight, blockReward, pblocktemplate->txoutMasternode, pblocktemplate->voutSuperblock); // LogPrintf("CreateNewBlock -- nBlockHeight %d blockReward %lld txoutMasternode %s coinbaseTx %s", - // nHeight, blockReward, pblock->txoutMasternode.ToString(), coinbaseTx.ToString()); + // nHeight, blockReward, pblocktemplate->txoutMasternode.ToString(), coinbaseTx.ToString()); pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx)); pblocktemplate->vTxFees[0] = -nFees; diff --git a/src/miner.h b/src/miner.h index 5934492c7..7770e95ba 100644 --- a/src/miner.h +++ b/src/miner.h @@ -30,6 +30,8 @@ struct CBlockTemplate CBlock block; std::vector vTxFees; std::vector vTxSigOps; + CTxOut txoutMasternode; // masternode payment + std::vector voutSuperblock; // superblock payment }; // Container for tracking updates to ancestor feerate as we include (parent) diff --git a/src/primitives/block.h b/src/primitives/block.h index dbf80237c..dda9a9d60 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -76,8 +76,6 @@ public: std::vector vtx; // memory only - mutable CTxOut txoutMasternode; // masternode payment - mutable std::vector voutSuperblock; // superblock payment mutable bool fChecked; CBlock() @@ -103,8 +101,6 @@ public: { CBlockHeader::SetNull(); vtx.clear(); - txoutMasternode = CTxOut(); - voutSuperblock.clear(); fChecked = false; } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 0ded5a6c1..723fc698f 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -699,21 +699,21 @@ UniValue getblocktemplate(const JSONRPCRequest& request) result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); UniValue masternodeObj(UniValue::VOBJ); - if(pblock->txoutMasternode != CTxOut()) { + if(pblocktemplate->txoutMasternode != CTxOut()) { CTxDestination address1; - ExtractDestination(pblock->txoutMasternode.scriptPubKey, address1); + ExtractDestination(pblocktemplate->txoutMasternode.scriptPubKey, address1); CBitcoinAddress address2(address1); masternodeObj.push_back(Pair("payee", address2.ToString().c_str())); - masternodeObj.push_back(Pair("script", HexStr(pblock->txoutMasternode.scriptPubKey))); - masternodeObj.push_back(Pair("amount", pblock->txoutMasternode.nValue)); + masternodeObj.push_back(Pair("script", HexStr(pblocktemplate->txoutMasternode.scriptPubKey))); + masternodeObj.push_back(Pair("amount", pblocktemplate->txoutMasternode.nValue)); } result.push_back(Pair("masternode", masternodeObj)); result.push_back(Pair("masternode_payments_started", pindexPrev->nHeight + 1 > consensusParams.nMasternodePaymentsStartBlock)); result.push_back(Pair("masternode_payments_enforced", sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))); UniValue superblockObjArray(UniValue::VARR); - if(pblock->voutSuperblock.size()) { - for (const auto& txout : pblock->voutSuperblock) { + if(pblocktemplate->voutSuperblock.size()) { + for (const auto& txout : pblocktemplate->voutSuperblock) { UniValue entry(UniValue::VOBJ); CTxDestination address1; ExtractDestination(txout.scriptPubKey, address1);