Move block template specific stuff from CBlock to CBlockTemplate (#2195)

This commit is contained in:
UdjinM6 2018-07-28 16:51:29 +03:00 committed by GitHub
parent 3d002c9463
commit 96435288fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 12 deletions

View File

@ -170,9 +170,9 @@ std::unique_ptr<CBlockTemplate> 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;

View File

@ -30,6 +30,8 @@ struct CBlockTemplate
CBlock block;
std::vector<CAmount> vTxFees;
std::vector<int64_t> vTxSigOps;
CTxOut txoutMasternode; // masternode payment
std::vector<CTxOut> voutSuperblock; // superblock payment
};
// Container for tracking updates to ancestor feerate as we include (parent)

View File

@ -76,8 +76,6 @@ public:
std::vector<CTransactionRef> vtx;
// memory only
mutable CTxOut txoutMasternode; // masternode payment
mutable std::vector<CTxOut> voutSuperblock; // superblock payment
mutable bool fChecked;
CBlock()
@ -103,8 +101,6 @@ public:
{
CBlockHeader::SetNull();
vtx.clear();
txoutMasternode = CTxOut();
voutSuperblock.clear();
fChecked = false;
}

View File

@ -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);