Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | static UniValue getmininginfo(const Config &config, | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("blocks", int(chainActive.Height())); | obj.pushKV("blocks", int(chainActive.Height())); | ||||
obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); | obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); | ||||
obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); | obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); | ||||
obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | ||||
obj.push_back( | obj.pushKV("blockprioritypercentage", | ||||
Pair("blockprioritypercentage", | |||||
uint8_t(gArgs.GetArg("-blockprioritypercentage", | uint8_t(gArgs.GetArg("-blockprioritypercentage", | ||||
DEFAULT_BLOCK_PRIORITY_PERCENTAGE)))); | DEFAULT_BLOCK_PRIORITY_PERCENTAGE))); | ||||
obj.pushKV("errors", GetWarnings("statusbar")); | obj.pushKV("errors", GetWarnings("statusbar")); | ||||
obj.pushKV("networkhashps", getnetworkhashps(config, request)); | obj.pushKV("networkhashps", getnetworkhashps(config, request)); | ||||
obj.pushKV("pooledtx", uint64_t(mempool.size())); | obj.pushKV("pooledtx", uint64_t(mempool.size())); | ||||
obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | ||||
return obj; | return obj; | ||||
} | } | ||||
// NOTE: Unlike wallet RPC (which use BCH values), mining RPCs follow GBT (BIP | // NOTE: Unlike wallet RPC (which use BCH values), mining RPCs follow GBT (BIP | ||||
▲ Show 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | for (const auto &it : pblock->vtx) { | ||||
int64_t nTxSigOps = | int64_t nTxSigOps = | ||||
pblocktemplate->entries[index_in_template].sigOpCount; | pblocktemplate->entries[index_in_template].sigOpCount; | ||||
entry.pushKV("sigops", nTxSigOps); | entry.pushKV("sigops", nTxSigOps); | ||||
transactions.push_back(entry); | transactions.push_back(entry); | ||||
} | } | ||||
UniValue aux(UniValue::VOBJ); | UniValue aux(UniValue::VOBJ); | ||||
aux.push_back( | aux.pushKV("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())); | ||||
Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); | |||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); | arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); | ||||
UniValue aMutable(UniValue::VARR); | UniValue aMutable(UniValue::VARR); | ||||
aMutable.push_back("time"); | aMutable.push_back("time"); | ||||
aMutable.push_back("transactions"); | aMutable.push_back("transactions"); | ||||
aMutable.push_back("prevblock"); | aMutable.push_back("prevblock"); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("capabilities", aCaps); | result.pushKV("capabilities", aCaps); | ||||
result.pushKV("version", pblock->nVersion); | result.pushKV("version", pblock->nVersion); | ||||
result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); | result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); | ||||
result.pushKV("transactions", transactions); | result.pushKV("transactions", transactions); | ||||
result.pushKV("coinbaseaux", aux); | result.pushKV("coinbaseaux", aux); | ||||
result.push_back(Pair("coinbasevalue", | result.pushKV("coinbasevalue", | ||||
int64_t(pblock->vtx[0]->vout[0].nValue / SATOSHI))); | int64_t(pblock->vtx[0]->vout[0].nValue / SATOSHI)); | ||||
result.push_back(Pair("longpollid", | result.pushKV("longpollid", | ||||
chainActive.Tip()->GetBlockHash().GetHex() + | chainActive.Tip()->GetBlockHash().GetHex() + | ||||
i64tostr(nTransactionsUpdatedLast))); | i64tostr(nTransactionsUpdatedLast)); | ||||
result.pushKV("target", hashTarget.GetHex()); | result.pushKV("target", hashTarget.GetHex()); | ||||
result.push_back( | result.pushKV("mintime", int64_t(pindexPrev->GetMedianTimePast()) + 1); | ||||
Pair("mintime", int64_t(pindexPrev->GetMedianTimePast()) + 1)); | |||||
result.pushKV("mutable", aMutable); | result.pushKV("mutable", aMutable); | ||||
result.pushKV("noncerange", "00000000ffffffff"); | result.pushKV("noncerange", "00000000ffffffff"); | ||||
// FIXME: Allow for mining block greater than 1M. | // FIXME: Allow for mining block greater than 1M. | ||||
result.push_back( | result.pushKV("sigoplimit", GetMaxBlockSigOpsCount(DEFAULT_MAX_BLOCK_SIZE)); | ||||
Pair("sigoplimit", GetMaxBlockSigOpsCount(DEFAULT_MAX_BLOCK_SIZE))); | |||||
result.pushKV("sizelimit", DEFAULT_MAX_BLOCK_SIZE); | result.pushKV("sizelimit", DEFAULT_MAX_BLOCK_SIZE); | ||||
result.pushKV("curtime", pblock->GetBlockTime()); | result.pushKV("curtime", pblock->GetBlockTime()); | ||||
result.pushKV("bits", strprintf("%08x", pblock->nBits)); | result.pushKV("bits", strprintf("%08x", pblock->nBits)); | ||||
result.pushKV("height", int64_t(pindexPrev->nHeight) + 1); | result.pushKV("height", int64_t(pindexPrev->nHeight) + 1); | ||||
return result; | return result; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |