File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ static bool rest_block(HTTPRequest* req,
217217 return RESTERR (req, HTTP_NOT_FOUND, hashStr + " not found" );
218218 }
219219
220- if (fHavePruned && ! (pblockindex-> nStatus & BLOCK_HAVE_DATA) && pblockindex-> nTx > 0 )
220+ if (IsBlockPruned (pblockindex) )
221221 return RESTERR (req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)" );
222222
223223 if (!ReadBlockFromDisk (block, pblockindex, Params ().GetConsensus ()))
Original file line number Diff line number Diff line change @@ -742,7 +742,7 @@ static UniValue getblockheader(const JSONRPCRequest& request)
742742static CBlock GetBlockChecked (const CBlockIndex* pblockindex)
743743{
744744 CBlock block;
745- if (fHavePruned && ! (pblockindex-> nStatus & BLOCK_HAVE_DATA) && pblockindex-> nTx > 0 ) {
745+ if (IsBlockPruned (pblockindex) ) {
746746 throw JSONRPCError (RPC_MISC_ERROR, " Block not available (pruned data)" );
747747 }
748748
Original file line number Diff line number Diff line change @@ -497,4 +497,10 @@ bool DumpMempool();
497497/* * Load the mempool from disk. */
498498bool LoadMempool ();
499499
500+ // ! Check whether the block associated with this index entry is pruned or not.
501+ inline bool IsBlockPruned (const CBlockIndex* pblockindex)
502+ {
503+ return (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0 );
504+ }
505+
500506#endif // BITCOIN_VALIDATION_H
You can’t perform that action at this time.
0 commit comments