mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
Merge c2f2abd0a4 into merged_master (Bitcoin PR bitcoin/bitcoin#27125)
This commit is contained in:
commit
b1d470027d
33 changed files with 195 additions and 176 deletions
|
|
@ -87,10 +87,7 @@ using node::BlockMap;
|
|||
using node::CBlockIndexHeightOnlyComparator;
|
||||
using node::CBlockIndexWorkComparator;
|
||||
using node::fReindex;
|
||||
using node::ReadBlockFromDisk;
|
||||
using node::SnapshotMetadata;
|
||||
using node::UndoReadFromDisk;
|
||||
using node::UnlinkPrunedFiles;
|
||||
|
||||
/** Maximum kilobytes for transactions to store for processing during reorg */
|
||||
static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000;
|
||||
|
|
@ -2060,7 +2057,7 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
|
|||
bool fClean = true;
|
||||
|
||||
CBlockUndo blockUndo;
|
||||
if (!UndoReadFromDisk(blockUndo, pindex)) {
|
||||
if (!m_blockman.UndoReadFromDisk(blockUndo, *pindex)) {
|
||||
error("DisconnectBlock(): failure reading undo data");
|
||||
return DISCONNECT_FAILED;
|
||||
}
|
||||
|
|
@ -2825,7 +2822,7 @@ bool Chainstate::FlushStateToDisk(
|
|||
if (fFlushForPrune) {
|
||||
LOG_TIME_MILLIS_WITH_CATEGORY("unlink pruned files", BCLog::BENCH);
|
||||
|
||||
UnlinkPrunedFiles(setFilesToPrune);
|
||||
m_blockman.UnlinkPrunedFiles(setFilesToPrune);
|
||||
}
|
||||
m_last_write = nNow;
|
||||
}
|
||||
|
|
@ -3015,7 +3012,7 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
|
|||
// Read block from disk.
|
||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||
CBlock& block = *pblock;
|
||||
if (!ReadBlockFromDisk(block, pindexDelete, m_chainman.GetConsensus())) {
|
||||
if (!m_blockman.ReadBlockFromDisk(block, *pindexDelete)) {
|
||||
return error("DisconnectTip(): Failed to read block");
|
||||
}
|
||||
// Apply the block atomically to the chain state.
|
||||
|
|
@ -3132,7 +3129,7 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
|
|||
std::shared_ptr<const CBlock> pthisBlock;
|
||||
if (!pblock) {
|
||||
std::shared_ptr<CBlock> pblockNew = std::make_shared<CBlock>();
|
||||
if (!ReadBlockFromDisk(*pblockNew, pindexNew, m_chainman.GetConsensus())) {
|
||||
if (!m_blockman.ReadBlockFromDisk(*pblockNew, *pindexNew)) {
|
||||
return AbortNode(state, "Failed to read block");
|
||||
}
|
||||
pthisBlock = pblockNew;
|
||||
|
|
@ -4683,7 +4680,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
|
|||
}
|
||||
CBlock block;
|
||||
// check level 0: read from disk
|
||||
if (!ReadBlockFromDisk(block, pindex, consensus_params)) {
|
||||
if (!chainstate.m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
LogPrintf("Verification error: ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return VerifyDBResult::CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
|
|
@ -4697,7 +4694,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
|
|||
if (nCheckLevel >= 2 && pindex) {
|
||||
CBlockUndo undo;
|
||||
if (!pindex->GetUndoPos().IsNull()) {
|
||||
if (!UndoReadFromDisk(undo, pindex)) {
|
||||
if (!chainstate.m_blockman.UndoReadFromDisk(undo, *pindex)) {
|
||||
LogPrintf("Verification error: found bad undo data at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return VerifyDBResult::CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
|
|
@ -4749,7 +4746,7 @@ VerifyDBResult CVerifyDB::VerifyDB(
|
|||
uiInterface.ShowProgress(_("Verifying blocks…").translated, percentageDone, false);
|
||||
pindex = chainstate.m_chain.Next(pindex);
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, pindex, consensus_params)) {
|
||||
if (!chainstate.m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
LogPrintf("Verification error: ReadBlockFromDisk failed at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
return VerifyDBResult::CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
|
|
@ -4778,7 +4775,7 @@ bool Chainstate::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& in
|
|||
AssertLockHeld(cs_main);
|
||||
// TODO: merge with ConnectBlock
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, pindex, m_chainman.GetConsensus())) {
|
||||
if (!m_blockman.ReadBlockFromDisk(block, *pindex)) {
|
||||
return error("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
}
|
||||
|
||||
|
|
@ -4830,7 +4827,7 @@ bool Chainstate::ReplayBlocks()
|
|||
while (pindexOld != pindexFork) {
|
||||
if (pindexOld->nHeight > 0) { // Never disconnect the genesis block.
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, pindexOld, m_chainman.GetConsensus())) {
|
||||
if (!m_blockman.ReadBlockFromDisk(block, *pindexOld)) {
|
||||
return error("RollbackBlock(): ReadBlockFromDisk() failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
|
||||
}
|
||||
LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
|
||||
|
|
@ -5141,7 +5138,7 @@ void Chainstate::LoadExternalBlockFile(
|
|||
while (range.first != range.second) {
|
||||
std::multimap<uint256, FlatFilePos>::iterator it = range.first;
|
||||
std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBlock>();
|
||||
if (ReadBlockFromDisk(*pblockrecursive, it->second, params.GetConsensus())) {
|
||||
if (m_blockman.ReadBlockFromDisk(*pblockrecursive, it->second)) {
|
||||
LogPrint(BCLog::REINDEX, "%s: Processing out of order child %s of %s\n", __func__, pblockrecursive->GetHash().ToString(),
|
||||
head.ToString());
|
||||
LOCK(cs_main);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue