aboutsummaryrefslogtreecommitdiff
path: root/src/rpcblockchain.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-05-11 16:33:41 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-05-11 16:40:58 +0200
commit7e0e7f823f87e93cc6b2de9779961dc2a5119472 (patch)
tree305eec8c56950b2c63b5557550f92ac09cc6961a /src/rpcblockchain.cpp
parentc1409d11ad30ff6da37d8bcabe374d42edacb41d (diff)
parent03c56872b532d111645f83f4cb80c36a3e46d54f (diff)
Merge pull request #6058
03c5687 appropriate response when trying to get a block in pruned mode (Jonas Schnelli) 1b2e555 add autoprune information to RPC "getblockchaininfo" (Jonas Schnelli)
Diffstat (limited to 'src/rpcblockchain.cpp')
-rw-r--r--src/rpcblockchain.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index ed32ee7723..ecf8e8bcc6 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -299,6 +299,9 @@ Value getblock(const Array& params, bool fHelp)
CBlock block;
CBlockIndex* pblockindex = mapBlockIndex[hash];
+ if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
+ throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
+
if(!ReadBlockFromDisk(block, pblockindex))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
@@ -492,6 +495,15 @@ Value getblockchaininfo(const Array& params, bool fHelp)
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
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));
+ if (fPruneMode)
+ {
+ CBlockIndex *block = chainActive.Tip();
+ while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA))
+ block = block->pprev;
+
+ obj.push_back(Pair("pruneheight", block->nHeight));
+ }
return obj;
}