Skip to content

Commit

Permalink
Move block template specific stuff from CBlock to CBlockTemplate (das…
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 authored and CryptoCentric committed Apr 25, 2019
1 parent 4083014 commit dd7acee
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,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;
Expand Down
2 changes: 2 additions & 0 deletions src/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class CBlock : public CBlockHeader
std::vector<CTransactionRef> vtx;

// memory only
mutable CTxOut txoutMasternode; // masternode payment
mutable std::vector<CTxOut> voutSuperblock; // superblock payment
mutable bool fChecked;

CBlock()
Expand All @@ -106,8 +104,6 @@ class CBlock : public CBlockHeader
{
CBlockHeader::SetNull();
vtx.clear();
txoutMasternode = CTxOut();
voutSuperblock.clear();
fChecked = false;
}

Expand Down
12 changes: 6 additions & 6 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,21 +702,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);
Expand Down

0 comments on commit dd7acee

Please sign in to comment.