Browse Source

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)
0.13
Wladimir J. van der Laan 10 years ago
parent
commit
7e0e7f823f
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 3
      src/rest.cpp
  2. 12
      src/rpcblockchain.cpp

3
src/rest.cpp

@ -197,6 +197,9 @@ static bool rest_block(AcceptedConnection* conn, @@ -197,6 +197,9 @@ static bool rest_block(AcceptedConnection* conn,
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
pblockindex = mapBlockIndex[hash];
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not available (pruned data)");
if (!ReadBlockFromDisk(block, pblockindex))
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
}

12
src/rpcblockchain.cpp

@ -299,6 +299,9 @@ Value getblock(const Array& params, bool fHelp) @@ -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) @@ -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;
}

Loading…
Cancel
Save