Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show All 22 Lines | |||||
#include <streams.h> | #include <streams.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <txdb.h> | #include <txdb.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
#include <versionbitsinfo.h> // For VersionBitsDeploymentInfo | |||||
#include <warnings.h> | #include <warnings.h> | ||||
#include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||
#include <boost/thread/thread.hpp> // boost::thread::interrupt | #include <boost/thread/thread.hpp> // boost::thread::interrupt | ||||
#include <cassert> | #include <cassert> | ||||
#include <condition_variable> | #include <condition_variable> | ||||
#include <cstdint> | #include <cstdint> | ||||
▲ Show 20 Lines • Show All 1,231 Lines • ▼ Show 20 Lines | 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); | ||||
} | } | ||||
static void BIP9SoftForkDescPushBack(UniValue &softforks, | static void BIP9SoftForkDescPushBack(UniValue &softforks, | ||||
const std::string &name, | |||||
const Consensus::Params &consensusParams, | const Consensus::Params &consensusParams, | ||||
Consensus::DeploymentPos id) | Consensus::DeploymentPos id) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
// For BIP9 deployments. | // For BIP9 deployments. | ||||
// Deployments (e.g. testdummy) with timeout value before Jan 1, 2009 are | // Deployments (e.g. testdummy) with timeout value before Jan 1, 2009 are | ||||
// hidden. A timeout value of 0 guarantees a softfork will never be | // hidden. A timeout value of 0 guarantees a softfork will never be | ||||
// activated. This is used when merging logic to implement a proposed | // activated. This is used when merging logic to implement a proposed | ||||
// softfork without a specified deployment schedule. | // softfork without a specified deployment schedule. | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static void BIP9SoftForkDescPushBack(UniValue &softforks, | ||||
UniValue rv(UniValue::VOBJ); | UniValue rv(UniValue::VOBJ); | ||||
rv.pushKV("type", "bip9"); | rv.pushKV("type", "bip9"); | ||||
rv.pushKV("bip9", bip9); | rv.pushKV("bip9", bip9); | ||||
if (ThresholdState::ACTIVE == thresholdState) { | if (ThresholdState::ACTIVE == thresholdState) { | ||||
rv.pushKV("height", since_height); | rv.pushKV("height", since_height); | ||||
} | } | ||||
rv.pushKV("active", ThresholdState::ACTIVE == thresholdState); | rv.pushKV("active", ThresholdState::ACTIVE == thresholdState); | ||||
softforks.pushKV(name, rv); | softforks.pushKV(VersionBitsDeploymentInfo[id].name, 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 " | ||||
Show All 33 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getblockchaininfo", "") + | HelpExampleCli("getblockchaininfo", "") + | ||||
HelpExampleRpc("getblockchaininfo", "")); | HelpExampleRpc("getblockchaininfo", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CChainParams &chainparams = config.GetChainParams(); | |||||
const CBlockIndex *tip = chainActive.Tip(); | const CBlockIndex *tip = chainActive.Tip(); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | obj.pushKV("chain", chainparams.NetworkIDString()); | ||||
obj.pushKV("blocks", int(chainActive.Height())); | obj.pushKV("blocks", int(chainActive.Height())); | ||||
obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); | obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); | ||||
obj.pushKV("bestblockhash", tip->GetBlockHash().GetHex()); | obj.pushKV("bestblockhash", tip->GetBlockHash().GetHex()); | ||||
obj.pushKV("difficulty", double(GetDifficulty(tip))); | obj.pushKV("difficulty", double(GetDifficulty(tip))); | ||||
obj.pushKV("mediantime", int64_t(tip->GetMedianTimePast())); | obj.pushKV("mediantime", int64_t(tip->GetMedianTimePast())); | ||||
obj.pushKV("verificationprogress", | obj.pushKV("verificationprogress", | ||||
GuessVerificationProgress(Params().TxData(), tip)); | GuessVerificationProgress(Params().TxData(), tip)); | ||||
obj.pushKV("initialblockdownload", IsInitialBlockDownload()); | obj.pushKV("initialblockdownload", IsInitialBlockDownload()); | ||||
Show All 14 Lines | if (fPruneMode) { | ||||
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); | ||||
} | } | ||||
} | } | ||||
UniValue softforks(UniValue::VOBJ); | UniValue softforks(UniValue::VOBJ); | ||||
BIP9SoftForkDescPushBack(softforks, "testdummy", | for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { | ||||
config.GetChainParams().GetConsensus(), | BIP9SoftForkDescPushBack(softforks, chainparams.GetConsensus(), | ||||
Consensus::DEPLOYMENT_TESTDUMMY); | Consensus::DeploymentPos(i)); | ||||
} | |||||
obj.pushKV("softforks", softforks); | 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 { | ||||
▲ Show 20 Lines • Show All 1,178 Lines • Show Last 20 Lines |