Skip to content

Commit

Permalink
Allow RPC retrieval of block size limit and votes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgenr8 committed Mar 19, 2017
1 parent 37082d6 commit 9f33da5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
result.push_back(Pair("sizelimit", blockindex->nMaxBlockSize));
result.push_back(Pair("sizelimitvote", blockindex->nMaxBlockSizeVote));

if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
Expand Down Expand Up @@ -118,6 +120,8 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
result.push_back(Pair("sizelimit", blockindex->nMaxBlockSize));
result.push_back(Pair("sizelimitvote", blockindex->nMaxBlockSizeVote));

if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
Expand Down Expand Up @@ -322,6 +326,9 @@ UniValue getblockheader(const UniValue& params, bool fHelp)
" \"nonce\" : n, (numeric) The nonce\n"
" \"bits\" : \"1d00ffff\", (string) The bits\n"
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
" \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n"
" \"sizelimit\" : n, (numeric) The block size limit as of this block\n"
" \"sizelimitvote\" : n, (numeric) This block's size limit vote\n"
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\", (string) The hash of the next block\n"
" \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n"
Expand Down Expand Up @@ -386,6 +393,8 @@ UniValue getblock(const UniValue& params, bool fHelp)
" \"bits\" : \"1d00ffff\", (string) The bits\n"
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
" \"chainwork\" : \"xxxx\", (string) Expected number of hashes required to produce the chain up to this block (in hex)\n"
" \"sizelimit\" : n, (numeric) The block size limit as of this block\n"
" \"sizelimitvote\" : n, (numeric) This block's sizelimit vote\n"
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
"}\n"
Expand Down Expand Up @@ -636,6 +645,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
" \"pruned\": xx, (boolean) if the blocks are subject to pruning\n"
" \"pruneheight\": xxxxxx, (numeric) heighest block available\n"
" \"sizelimit\" : n, (numeric) The block size limit as of the last block\n"
" \"softforks\": [ (array) status of softforks in progress\n"
" {\n"
" \"id\": \"xxxx\", (string) name of softfork\n"
Expand Down Expand Up @@ -673,6 +683,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode));
obj.push_back(Pair("sizelimit", chainActive.Tip()->nMaxBlockSize));

const Consensus::Params& consensusParams = Params().GetConsensus();
CBlockIndex* tip = chainActive.Tip();
Expand Down
2 changes: 2 additions & 0 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
" \"pooledtx\": n (numeric) The size of the mem pool\n"
" \"testnet\": true|false (boolean) If using testnet or not\n"
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
" \"sizelimit\" : n, (numeric) The block size limit as of the last block\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmininginfo", "")
Expand All @@ -267,6 +268,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
obj.push_back(Pair("chain", Params().NetworkIDString()));
obj.push_back(Pair("sizelimit", chainActive.Tip()->nMaxBlockSize));
obj.push_back(Pair("generate", getgenerate(params, false)));
return obj;
}
Expand Down
2 changes: 2 additions & 0 deletions src/rpcmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n"
" \"sizelimit\" : n, (numeric) The block size limit as of the last block\n"
" \"errors\": \"...\" (string) any error messages\n"
"}\n"
"\nExamples:\n"
Expand Down Expand Up @@ -103,6 +104,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
obj.push_back(Pair("sizelimit", chainActive.Tip()->nMaxBlockSize));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
return obj;
}
Expand Down

0 comments on commit 9f33da5

Please sign in to comment.