Skip to content

Commit

Permalink
Backport size_on_disk to RPC call getblockchaininfo.
Browse files Browse the repository at this point in the history
This commit is extracted from upstream PR:
bitcoin/bitcoin#11367
  • Loading branch information
leto authored and garethtdavies committed May 30, 2019
1 parent ed40a34 commit c347d88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.h
Expand Up @@ -925,6 +925,8 @@ extern CBlockTreeDB *pblocktree;
*/
int GetSpendHeight(const CCoinsViewCache& inputs);

uint64_t CalculateCurrentUsage();

/** Return a CMutableTransaction with contextual default values based on set of consensus rules at height */
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight);

Expand Down
3 changes: 3 additions & 0 deletions src/rpc/blockchain.cpp
Expand Up @@ -919,6 +919,7 @@ void NetworkUpgradeDescPushBack(
}
}


UniValue getblockchaininfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
Expand All @@ -936,6 +937,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\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"
" \"commitments\": xxxxxx, (numeric) the current number of note commitments in the commitment tree\n"
" \"softforks\": [ (array) status of softforks in progress\n"
" {\n"
Expand Down Expand Up @@ -979,6 +981,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode));
obj.push_back(Pair("size_on_disk", CalculateCurrentUsage()));

SproutMerkleTree tree;
pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree);
Expand Down

0 comments on commit c347d88

Please sign in to comment.