mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-12 13:41:52 +00:00
WIP: added get_info for cryptonote.
This commit is contained in:
parent
5424d869fa
commit
8f4b44cbf6
@ -20,6 +20,7 @@
|
||||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
#include <txdb.h>
|
||||
#include <net.h>
|
||||
#include <txmempool.h>
|
||||
#include <util.h>
|
||||
#include <utilstrencodings.h>
|
||||
@ -1383,6 +1384,76 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
|
||||
return obj;
|
||||
}
|
||||
|
||||
extern std::unique_ptr<CConnman> g_connman;
|
||||
|
||||
// Cryptonote RPC call
|
||||
UniValue get_info(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw std::runtime_error(
|
||||
"get_info\n"
|
||||
"Returns an object containing various state info regarding blockchain processing.\n"
|
||||
"\nResult:\n"
|
||||
"{\n"
|
||||
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
|
||||
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
|
||||
" \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n"
|
||||
" \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
|
||||
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
|
||||
" \"mediantime\": xxxxxx, (numeric) median time for the current best block\n"
|
||||
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n"
|
||||
" \"initialblockdownload\": xxxx, (bool) (debug information) estimate of whether this node is in Initial Block Download mode.\n"
|
||||
" \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n"
|
||||
" \"size_on_disk\": xxxxxx, (numeric) the estimated size of the block and undo files on disk\n"
|
||||
" \"pruned\": xx, (boolean) if the blocks are subject to pruning\n"
|
||||
" \"pruneheight\": xxxxxx, (numeric) lowest-height complete block stored (only present if pruning is enabled)\n"
|
||||
" \"automatic_pruning\": xx, (boolean) whether automatic pruning is enabled (only present if pruning is enabled)\n"
|
||||
" \"prune_target_size\": xxxxxx, (numeric) the target size used by pruning (only present if automatic pruning is enabled)\n"
|
||||
" \"softforks\": [ (array) status of softforks in progress\n"
|
||||
" {\n"
|
||||
" \"id\": \"xxxx\", (string) name of softfork\n"
|
||||
" \"version\": xx, (numeric) block version\n"
|
||||
" \"reject\": { (object) progress toward rejecting pre-softfork blocks\n"
|
||||
" \"status\": xx, (boolean) true if threshold reached\n"
|
||||
" },\n"
|
||||
" }, ...\n"
|
||||
" ],\n"
|
||||
" \"bip9_softforks\": { (object) status of BIP9 softforks in progress\n"
|
||||
" \"xxxx\" : { (string) name of the softfork\n"
|
||||
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\"\n"
|
||||
" \"bit\": xx, (numeric) the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)\n"
|
||||
" \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
|
||||
" \"timeout\": xx, (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n"
|
||||
" \"since\": xx, (numeric) height of the first block to which the status applies\n"
|
||||
" \"statistics\": { (object) numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)\n"
|
||||
" \"period\": xx, (numeric) the length in blocks of the BIP9 signalling period \n"
|
||||
" \"threshold\": xx, (numeric) the number of blocks with the version bit set required to activate the feature \n"
|
||||
" \"elapsed\": xx, (numeric) the number of blocks elapsed since the beginning of the current period \n"
|
||||
" \"count\": xx, (numeric) the number of blocks with the version bit set in the current period \n"
|
||||
" \"possible\": xx (boolean) returns false if there are not enough blocks left in this period to pass activation threshold \n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" \"warnings\" : \"...\", (string) any network and blockchain warnings.\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getblockchaininfo", "")
|
||||
+ HelpExampleRpc("getblockchaininfo", "")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("mainnet", Params().NetworkIDString() == "main"));
|
||||
obj.push_back(Pair("testnet", Params().NetworkIDString() == "test"));
|
||||
obj.push_back(Pair("height", (int)chainActive.Height()));
|
||||
obj.push_back(Pair("incoming_connections_count", g_connman->GetNodeCount(CConnman::CONNECTIONS_IN)));
|
||||
obj.push_back(Pair("outgoing_connections_count", g_connman->GetNodeCount(CConnman::CONNECTIONS_OUT)));
|
||||
obj.push_back(Pair("difficulty", (uint64_t)round(GetDifficulty())));
|
||||
obj.push_back(Pair("tx_pool_size", (int64_t) mempool.size()));
|
||||
obj.push_back(Pair("status", "OK"));
|
||||
return obj;
|
||||
}
|
||||
|
||||
/** Comparison function for sorting the getchaintips heads. */
|
||||
struct CompareBlocksByHeight
|
||||
{
|
||||
@ -1777,6 +1848,7 @@ static const CRPCCommand commands[] =
|
||||
// Cryptonote RPC APIs, used for mining pool.
|
||||
{ "blockchain", "getlastblockheader", &getlastblockheader, {} },
|
||||
{ "blockchain", "getblockheaderbyheight", &getblockheaderbyheight, {"height"} },
|
||||
{ "blockchain", "get_info", &get_info, {} },
|
||||
|
||||
/* Not shown in help */
|
||||
{ "hidden", "invalidateblock", &invalidateblock, {"blockhash"} },
|
||||
|
Loading…
x
Reference in New Issue
Block a user