Add previousbits field to getblocktemplate output (#2201)

* Add `previousbits` field to `getblocktemplate` output

* add comment to nPrevBits
This commit is contained in:
UdjinM6 2018-08-11 01:28:30 +03:00 committed by GitHub
parent c4ee2c89ef
commit 4cd969e3d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -182,6 +182,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
pblock->nNonce = 0;
pblocktemplate->nPrevBits = pindexPrev->nBits;
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(*pblock->vtx[0]);
CValidationState state;

View File

@ -30,6 +30,7 @@ struct CBlockTemplate
CBlock block;
std::vector<CAmount> vTxFees;
std::vector<int64_t> vTxSigOps;
uint32_t nPrevBits; // nBits of previous block (for subsidy calculation)
CTxOut txoutMasternode; // masternode payment
std::vector<CTxOut> voutSuperblock; // superblock payment
};

View File

@ -385,6 +385,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
" \"sizelimit\" : n, (numeric) limit of block size\n"
" \"curtime\" : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
" \"bits\" : \"xxxxxxxx\", (string) compressed target of next block\n"
" \"previousbits\" : \"xxxxxxxx\", (string) compressed target of current highest block\n"
" \"height\" : n (numeric) The height of the next block\n"
" \"masternode\" : { (json object) required masternode payee that must be included in the next block\n"
" \"payee\" : \"xxxx\", (string) payee address\n"
@ -696,6 +697,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
result.push_back(Pair("sizelimit", (int64_t)MaxBlockSize(fDIP0001ActiveAtTip)));
result.push_back(Pair("curtime", pblock->GetBlockTime()));
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
result.push_back(Pair("previousbits", strprintf("%08x", pblocktemplate->nPrevBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
UniValue masternodeObj(UniValue::VOBJ);