File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,9 @@ static bool rest_block(AcceptedConnection* conn,
197197 throw RESTERR (HTTP_NOT_FOUND, hashStr + " not found" );
198198
199199 pblockindex = mapBlockIndex[hash];
200+ if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0 )
201+ throw RESTERR (HTTP_NOT_FOUND, hashStr + " not available (pruned data)" );
202+
200203 if (!ReadBlockFromDisk (block, pblockindex))
201204 throw RESTERR (HTTP_NOT_FOUND, hashStr + " not found" );
202205 }
Original file line number Diff line number Diff line change @@ -299,6 +299,9 @@ Value getblock(const Array& params, bool fHelp)
299299 CBlock block;
300300 CBlockIndex* pblockindex = mapBlockIndex[hash];
301301
302+ if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0 )
303+ throw JSONRPCError (RPC_INTERNAL_ERROR, " Block not available (pruned data)" );
304+
302305 if (!ReadBlockFromDisk (block, pblockindex))
303306 throw JSONRPCError (RPC_INTERNAL_ERROR, " Can't read block from disk" );
304307
@@ -492,6 +495,15 @@ Value getblockchaininfo(const Array& params, bool fHelp)
492495 obj.push_back (Pair (" difficulty" , (double )GetDifficulty ()));
493496 obj.push_back (Pair (" verificationprogress" , Checkpoints::GuessVerificationProgress (Params ().Checkpoints (), chainActive.Tip ())));
494497 obj.push_back (Pair (" chainwork" , chainActive.Tip ()->nChainWork .GetHex ()));
498+ obj.push_back (Pair (" pruned" , fPruneMode ));
499+ if (fPruneMode )
500+ {
501+ CBlockIndex *block = chainActive.Tip ();
502+ while (block && block->pprev && (block->pprev ->nStatus & BLOCK_HAVE_DATA))
503+ block = block->pprev ;
504+
505+ obj.push_back (Pair (" pruneheight" , block->nHeight ));
506+ }
495507 return obj;
496508}
497509
You can’t perform that action at this time.
0 commit comments