Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,235 Lines • ▼ Show 20 Lines | static UniValue verifychain(const Config &config, | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
nCheckDepth = request.params[1].get_int(); | nCheckDepth = request.params[1].get_int(); | ||||
} | } | ||||
return CVerifyDB().VerifyDB(config, pcoinsTip.get(), nCheckLevel, | return CVerifyDB().VerifyDB(config, pcoinsTip.get(), nCheckLevel, | ||||
nCheckDepth); | nCheckDepth); | ||||
} | } | ||||
/** Implementation of IsSuperMajority with better feedback */ | |||||
static UniValue SoftForkMajorityDesc(int version, const CBlockIndex *pindex, | |||||
const Consensus::Params &consensusParams) { | |||||
UniValue rv(UniValue::VOBJ); | |||||
bool activated = false; | |||||
switch (version) { | |||||
case 2: | |||||
activated = pindex->nHeight >= consensusParams.BIP34Height; | |||||
break; | |||||
case 3: | |||||
activated = pindex->nHeight >= consensusParams.BIP66Height; | |||||
break; | |||||
case 4: | |||||
activated = pindex->nHeight >= consensusParams.BIP65Height; | |||||
break; | |||||
case 5: | |||||
activated = pindex->nHeight >= consensusParams.CSVHeight; | |||||
break; | |||||
} | |||||
rv.pushKV("status", activated); | |||||
return rv; | |||||
} | |||||
static UniValue SoftForkDesc(const std::string &name, int version, | |||||
const CBlockIndex *pindex, | |||||
const Consensus::Params &consensusParams) { | |||||
UniValue rv(UniValue::VOBJ); | |||||
rv.pushKV("id", name); | |||||
rv.pushKV("version", version); | |||||
rv.pushKV("reject", SoftForkMajorityDesc(version, pindex, consensusParams)); | |||||
return rv; | |||||
} | |||||
UniValue getblockchaininfo(const Config &config, | UniValue getblockchaininfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getblockchaininfo\n" | "getblockchaininfo\n" | ||||
"Returns an object containing various state info regarding " | "Returns an object containing various state info regarding " | ||||
"blockchain processing.\n" | "blockchain processing.\n" | ||||
"DEPRECATION WARNING: The 'softforks' output has been deprecated " | |||||
"and will be\n" | |||||
"removed v0.20. For the time being it will only be shown here when " | |||||
"bitcoind\n" | |||||
"is started with -deprecatedrpc=getblockchaininfo.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"chain\": \"xxxx\", (string) current network name " | " \"chain\": \"xxxx\", (string) current network name " | ||||
"as defined in BIP70 (main, test, regtest)\n" | "as defined in BIP70 (main, test, regtest)\n" | ||||
" \"blocks\": xxxxxx, (numeric) the current number of " | " \"blocks\": xxxxxx, (numeric) the current number of " | ||||
"blocks processed in the server\n" | "blocks processed in the server\n" | ||||
" \"headers\": xxxxxx, (numeric) the current number of " | " \"headers\": xxxxxx, (numeric) the current number of " | ||||
"headers we have validated\n" | "headers we have validated\n" | ||||
Show All 14 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
" \"pruned\": xx, (boolean) if the blocks are " | " \"pruned\": xx, (boolean) if the blocks are " | ||||
"subject to pruning\n" | "subject to pruning\n" | ||||
" \"pruneheight\": xxxxxx, (numeric) lowest-height " | " \"pruneheight\": xxxxxx, (numeric) lowest-height " | ||||
"complete block stored (only present if pruning is enabled)\n" | "complete block stored (only present if pruning is enabled)\n" | ||||
" \"automatic_pruning\": xx, (boolean) whether automatic " | " \"automatic_pruning\": xx, (boolean) whether automatic " | ||||
"pruning is enabled (only present if pruning is enabled)\n" | "pruning is enabled (only present if pruning is enabled)\n" | ||||
" \"prune_target_size\": xxxxxx, (numeric) the target size " | " \"prune_target_size\": xxxxxx, (numeric) the target size " | ||||
"used by pruning (only present if automatic pruning is enabled)\n" | "used by pruning (only present if automatic pruning is enabled)\n" | ||||
" \"softforks\": [ (array) DEPRECATED: 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" | |||||
" \"warnings\" : \"...\", (string) any network and " | " \"warnings\" : \"...\", (string) any network and " | ||||
"blockchain warnings.\n" | "blockchain warnings.\n" | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getblockchaininfo", "") + | HelpExampleCli("getblockchaininfo", "") + | ||||
HelpExampleRpc("getblockchaininfo", "")); | HelpExampleRpc("getblockchaininfo", "")); | ||||
} | } | ||||
Show All 26 Lines | if (fPruneMode) { | ||||
// if 0, execution bypasses the whole if block. | // if 0, execution bypasses the whole if block. | ||||
bool automatic_pruning = (gArgs.GetArg("-prune", 0) != 1); | bool automatic_pruning = (gArgs.GetArg("-prune", 0) != 1); | ||||
obj.pushKV("automatic_pruning", automatic_pruning); | obj.pushKV("automatic_pruning", automatic_pruning); | ||||
if (automatic_pruning) { | if (automatic_pruning) { | ||||
obj.pushKV("prune_target_size", nPruneTarget); | obj.pushKV("prune_target_size", nPruneTarget); | ||||
} | } | ||||
} | } | ||||
if (IsDeprecatedRPCEnabled(gArgs, "getblockchaininfo")) { | |||||
const Consensus::Params &consensusParams = | |||||
config.GetChainParams().GetConsensus(); | |||||
UniValue softforks(UniValue::VARR); | |||||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); | |||||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); | |||||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | |||||
softforks.push_back(SoftForkDesc("csv", 5, tip, consensusParams)); | |||||
obj.pushKV("softforks", softforks); | |||||
} | |||||
obj.pushKV("warnings", GetWarnings("statusbar")); | obj.pushKV("warnings", GetWarnings("statusbar")); | ||||
return obj; | return obj; | ||||
} | } | ||||
/** Comparison function for sorting the getchaintips heads. */ | /** Comparison function for sorting the getchaintips heads. */ | ||||
struct CompareBlocksByHeight { | struct CompareBlocksByHeight { | ||||
bool operator()(const CBlockIndex *a, const CBlockIndex *b) const { | bool operator()(const CBlockIndex *a, const CBlockIndex *b) const { | ||||
// Make sure that unequal blocks with the same height do not compare | // Make sure that unequal blocks with the same height do not compare | ||||
▲ Show 20 Lines • Show All 897 Lines • Show Last 20 Lines |