mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
move-mostly: Make fHavePruned a BlockMan member
[META] In the next commit, we move the clearing of fHavePruned to
BlockManager::Unload()
This commit is contained in:
parent
c96524113c
commit
3308ecd3fc
10 changed files with 35 additions and 38 deletions
|
|
@ -54,7 +54,6 @@ using node::BlockManager;
|
|||
using node::CCoinsStats;
|
||||
using node::CoinStatsHashType;
|
||||
using node::GetUTXOStats;
|
||||
using node::IsBlockPruned;
|
||||
using node::NodeContext;
|
||||
using node::ReadBlockFromDisk;
|
||||
using node::SnapshotMetadata;
|
||||
|
|
@ -161,7 +160,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
|
|||
return result;
|
||||
}
|
||||
|
||||
UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, TxVerbosity verbosity)
|
||||
UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, TxVerbosity verbosity)
|
||||
{
|
||||
UniValue result = blockheaderToJSON(tip, blockindex);
|
||||
|
||||
|
|
@ -180,7 +179,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
|
|||
case TxVerbosity::SHOW_DETAILS:
|
||||
case TxVerbosity::SHOW_DETAILS_AND_PREVOUT:
|
||||
CBlockUndo blockUndo;
|
||||
const bool have_undo{WITH_LOCK(::cs_main, return !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex))};
|
||||
const bool have_undo{WITH_LOCK(::cs_main, return !blockman.IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex))};
|
||||
|
||||
for (size_t i = 0; i < block.vtx.size(); ++i) {
|
||||
const CTransactionRef& tx = block.vtx.at(i);
|
||||
|
|
@ -565,11 +564,11 @@ static RPCHelpMan getblockheader()
|
|||
};
|
||||
}
|
||||
|
||||
static CBlock GetBlockChecked(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
static CBlock GetBlockChecked(BlockManager& blockman, const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
CBlock block;
|
||||
if (IsBlockPruned(pblockindex)) {
|
||||
if (blockman.IsBlockPruned(pblockindex)) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "Block not available (pruned data)");
|
||||
}
|
||||
|
||||
|
|
@ -583,11 +582,11 @@ static CBlock GetBlockChecked(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_RE
|
|||
return block;
|
||||
}
|
||||
|
||||
static CBlockUndo GetUndoChecked(const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
static CBlockUndo GetUndoChecked(BlockManager& blockman, const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
CBlockUndo blockUndo;
|
||||
if (IsBlockPruned(pblockindex)) {
|
||||
if (blockman.IsBlockPruned(pblockindex)) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "Undo data not available (pruned data)");
|
||||
}
|
||||
|
||||
|
|
@ -701,8 +700,8 @@ static RPCHelpMan getblock()
|
|||
CBlock block;
|
||||
const CBlockIndex* pblockindex;
|
||||
const CBlockIndex* tip;
|
||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||
{
|
||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||
LOCK(cs_main);
|
||||
pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
|
||||
tip = chainman.ActiveChain().Tip();
|
||||
|
|
@ -711,7 +710,7 @@ static RPCHelpMan getblock()
|
|||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||
}
|
||||
|
||||
block = GetBlockChecked(pblockindex);
|
||||
block = GetBlockChecked(chainman.m_blockman, pblockindex);
|
||||
}
|
||||
|
||||
if (verbosity <= 0)
|
||||
|
|
@ -731,7 +730,7 @@ static RPCHelpMan getblock()
|
|||
tx_verbosity = TxVerbosity::SHOW_DETAILS_AND_PREVOUT;
|
||||
}
|
||||
|
||||
return blockToJSON(block, tip, pblockindex, tx_verbosity);
|
||||
return blockToJSON(chainman.m_blockman, block, tip, pblockindex, tx_verbosity);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -1777,8 +1776,8 @@ static RPCHelpMan getblockstats()
|
|||
}
|
||||
}
|
||||
|
||||
const CBlock block = GetBlockChecked(pindex);
|
||||
const CBlockUndo blockUndo = GetUndoChecked(pindex);
|
||||
const CBlock block = GetBlockChecked(chainman.m_blockman, pindex);
|
||||
const CBlockUndo blockUndo = GetUndoChecked(chainman.m_blockman, pindex);
|
||||
|
||||
const bool do_all = stats.size() == 0; // Calculate everything if nothing selected (default)
|
||||
const bool do_mediantxsize = do_all || stats.count("mediantxsize") != 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue