From c66ff33db06dcea5ae7a814caf241035de79f05d Mon Sep 17 00:00:00 2001 From: Markus Nebel Date: Tue, 7 May 2019 11:58:44 +0200 Subject: [PATCH] add initialblockdownload and size_on_disk to getblockchaininfo rpc (#176) --- src/main.h | 3 +++ src/rpc/rpcblockchain.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/main.h b/src/main.h index d2d04298..899ce946 100644 --- a/src/main.h +++ b/src/main.h @@ -452,6 +452,9 @@ bool CheckBlock(const CBlock &block, CValidationState &state, bool fCheckPOW = t /** Context-dependent validity checks */ bool ContextualCheckBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindexPrev); +/* Calculate the amount of disk space the block & undo files currently use */ +uint64_t CalculateCurrentUsage(); + extern std::set setBlockIndexCandidates; class CBlockFileInfo diff --git a/src/rpc/rpcblockchain.cpp b/src/rpc/rpcblockchain.cpp index 49b5ffe4..6ba1a983 100644 --- a/src/rpc/rpcblockchain.cpp +++ b/src/rpc/rpcblockchain.cpp @@ -745,7 +745,10 @@ UniValue getblockchaininfo(const UniValue ¶ms, bool fHelp) " \"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) heighest block available\n" " \"softforks\": [ (array) status of softforks in progress\n" @@ -787,7 +790,9 @@ UniValue getblockchaininfo(const UniValue ¶ms, bool fHelp) obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(pnetMan->getActivePaymentNetwork()->Checkpoints(), pnetMan->getChainActive()->chainActive.Tip()))); + obj.push_back(Pair("initialblockdownload", pnetMan->getChainActive()->IsInitialBlockDownload())); obj.push_back(Pair("chainwork", pnetMan->getChainActive()->chainActive.Tip()->nChainWork.GetHex())); + obj.push_back(Pair("size_on_disk", CalculateCurrentUsage())); const Consensus::Params &consensusParams = pnetMan->getActivePaymentNetwork()->GetConsensus(); CBlockIndex *tip = pnetMan->getChainActive()->chainActive.Tip();