Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,245 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
" \"difficulty\": xxxxxx, (numeric) the current " | " \"difficulty\": xxxxxx, (numeric) the current " | ||||
"difficulty\n" | "difficulty\n" | ||||
" \"mediantime\": xxxxxx, (numeric) median time for the " | " \"mediantime\": xxxxxx, (numeric) median time for the " | ||||
"current best block\n" | "current best block\n" | ||||
" \"verificationprogress\": xxxx, (numeric) estimate of " | " \"verificationprogress\": xxxx, (numeric) estimate of " | ||||
"verification progress [0..1]\n" | "verification progress [0..1]\n" | ||||
" \"chainwork\": \"xxxx\" (string) total amount of work " | " \"chainwork\": \"xxxx\" (string) total amount of work " | ||||
"in active chain, in hexadecimal\n" | "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 " | " \"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\n" | "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 " | " \"softforks\": [ (array) status of softforks in " | ||||
"progress\n" | "progress\n" | ||||
" {\n" | " {\n" | ||||
" \"id\": \"xxxx\", (string) name of softfork\n" | " \"id\": \"xxxx\", (string) name of softfork\n" | ||||
" \"version\": xx, (numeric) block version\n" | " \"version\": xx, (numeric) block version\n" | ||||
" \"reject\": { (object) progress toward " | " \"reject\": { (object) progress toward " | ||||
"rejecting pre-softfork blocks\n" | "rejecting pre-softfork blocks\n" | ||||
" \"status\": xx, (boolean) true if threshold " | " \"status\": xx, (boolean) true if threshold " | ||||
Show All 17 Lines | UniValue getblockchaininfo(const Config &config, | ||||
obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); | obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1); | ||||
obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()); | obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()); | ||||
obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | ||||
obj.pushKV("mediantime", int64_t(chainActive.Tip()->GetMedianTimePast())); | obj.pushKV("mediantime", int64_t(chainActive.Tip()->GetMedianTimePast())); | ||||
obj.pushKV("verificationprogress", | obj.pushKV("verificationprogress", | ||||
GuessVerificationProgress(config.GetChainParams().TxData(), | GuessVerificationProgress(config.GetChainParams().TxData(), | ||||
chainActive.Tip())); | chainActive.Tip())); | ||||
obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex()); | obj.pushKV("chainwork", chainActive.Tip()->nChainWork.GetHex()); | ||||
obj.pushKV("size_on_disk", CalculateCurrentUsage()); | |||||
obj.pushKV("pruned", fPruneMode); | obj.pushKV("pruned", fPruneMode); | ||||
if (fPruneMode) { | |||||
CBlockIndex *block = chainActive.Tip(); | |||||
assert(block); | |||||
while (block->pprev && (block->pprev->nStatus.hasData())) { | |||||
block = block->pprev; | |||||
} | |||||
obj.pushKV("pruneheight", block->nHeight); | |||||
// if 0, execution bypasses the whole if block. | |||||
bool automatic_pruning = (gArgs.GetArg("-prune", 0) != 1); | |||||
obj.pushKV("automatic_pruning", automatic_pruning); | |||||
if (automatic_pruning) { | |||||
obj.pushKV("prune_target_size", nPruneTarget); | |||||
} | |||||
} | |||||
const Consensus::Params &consensusParams = | const Consensus::Params &consensusParams = | ||||
config.GetChainParams().GetConsensus(); | config.GetChainParams().GetConsensus(); | ||||
CBlockIndex *tip = chainActive.Tip(); | CBlockIndex *tip = chainActive.Tip(); | ||||
UniValue softforks(UniValue::VARR); | UniValue softforks(UniValue::VARR); | ||||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); | softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); | ||||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); | softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); | ||||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | ||||
softforks.push_back(SoftForkDesc("csv", 5, tip, consensusParams)); | softforks.push_back(SoftForkDesc("csv", 5, tip, consensusParams)); | ||||
obj.pushKV("softforks", softforks); | obj.pushKV("softforks", softforks); | ||||
if (fPruneMode) { | |||||
CBlockIndex *block = chainActive.Tip(); | |||||
while (block && block->pprev && block->pprev->nStatus.hasData()) { | |||||
block = block->pprev; | |||||
} | |||||
obj.pushKV("pruneheight", block->nHeight); | |||||
} | |||||
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 547 Lines • Show Last 20 Lines |