mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +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
|
|
@ -395,7 +395,7 @@ public:
|
|||
NodeContext* m_context{nullptr};
|
||||
};
|
||||
|
||||
bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active)
|
||||
bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active, const BlockManager& blockman)
|
||||
{
|
||||
if (!index) return false;
|
||||
if (block.m_hash) *block.m_hash = index->GetBlockHash();
|
||||
|
|
@ -405,10 +405,10 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec
|
|||
if (block.m_mtp_time) *block.m_mtp_time = index->GetMedianTimePast();
|
||||
if (block.m_in_active_chain) *block.m_in_active_chain = active[index->nHeight] == index;
|
||||
if (block.m_locator) { *block.m_locator = GetLocator(index); }
|
||||
if (block.m_next_block) FillBlock(active[index->nHeight] == index ? active[index->nHeight + 1] : nullptr, *block.m_next_block, lock, active);
|
||||
if (block.m_next_block) FillBlock(active[index->nHeight] == index ? active[index->nHeight + 1] : nullptr, *block.m_next_block, lock, active, blockman);
|
||||
if (block.m_data) {
|
||||
REVERSE_LOCK(lock);
|
||||
if (!ReadBlockFromDisk(*block.m_data, index, Params().GetConsensus())) block.m_data->SetNull();
|
||||
if (!blockman.ReadBlockFromDisk(*block.m_data, *index)) block.m_data->SetNull();
|
||||
}
|
||||
block.found = true;
|
||||
return true;
|
||||
|
|
@ -558,13 +558,13 @@ public:
|
|||
bool findBlock(const uint256& hash, const FoundBlock& block) override
|
||||
{
|
||||
WAIT_LOCK(cs_main, lock);
|
||||
return FillBlock(chainman().m_blockman.LookupBlockIndex(hash), block, lock, chainman().ActiveChain());
|
||||
return FillBlock(chainman().m_blockman.LookupBlockIndex(hash), block, lock, chainman().ActiveChain(), chainman().m_blockman);
|
||||
}
|
||||
bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock& block) override
|
||||
{
|
||||
WAIT_LOCK(cs_main, lock);
|
||||
const CChain& active = chainman().ActiveChain();
|
||||
return FillBlock(active.FindEarliestAtLeast(min_time, min_height), block, lock, active);
|
||||
return FillBlock(active.FindEarliestAtLeast(min_time, min_height), block, lock, active, chainman().m_blockman);
|
||||
}
|
||||
bool findAncestorByHeight(const uint256& block_hash, int ancestor_height, const FoundBlock& ancestor_out) override
|
||||
{
|
||||
|
|
@ -572,10 +572,10 @@ public:
|
|||
const CChain& active = chainman().ActiveChain();
|
||||
if (const CBlockIndex* block = chainman().m_blockman.LookupBlockIndex(block_hash)) {
|
||||
if (const CBlockIndex* ancestor = block->GetAncestor(ancestor_height)) {
|
||||
return FillBlock(ancestor, ancestor_out, lock, active);
|
||||
return FillBlock(ancestor, ancestor_out, lock, active, chainman().m_blockman);
|
||||
}
|
||||
}
|
||||
return FillBlock(nullptr, ancestor_out, lock, active);
|
||||
return FillBlock(nullptr, ancestor_out, lock, active, chainman().m_blockman);
|
||||
}
|
||||
bool findAncestorByHash(const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override
|
||||
{
|
||||
|
|
@ -583,7 +583,7 @@ public:
|
|||
const CBlockIndex* block = chainman().m_blockman.LookupBlockIndex(block_hash);
|
||||
const CBlockIndex* ancestor = chainman().m_blockman.LookupBlockIndex(ancestor_hash);
|
||||
if (block && ancestor && block->GetAncestor(ancestor->nHeight) != ancestor) ancestor = nullptr;
|
||||
return FillBlock(ancestor, ancestor_out, lock, chainman().ActiveChain());
|
||||
return FillBlock(ancestor, ancestor_out, lock, chainman().ActiveChain(), chainman().m_blockman);
|
||||
}
|
||||
bool findCommonAncestor(const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
|
||||
{
|
||||
|
|
@ -595,9 +595,9 @@ public:
|
|||
// Using & instead of && below to avoid short circuiting and leaving
|
||||
// output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
|
||||
// compiler warnings.
|
||||
return int{FillBlock(ancestor, ancestor_out, lock, active)} &
|
||||
int{FillBlock(block1, block1_out, lock, active)} &
|
||||
int{FillBlock(block2, block2_out, lock, active)};
|
||||
return int{FillBlock(ancestor, ancestor_out, lock, active, chainman().m_blockman)} &
|
||||
int{FillBlock(block1, block1_out, lock, active, chainman().m_blockman)} &
|
||||
int{FillBlock(block2, block2_out, lock, active, chainman().m_blockman)};
|
||||
}
|
||||
void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }
|
||||
double guessVerificationProgress(const uint256& block_hash) override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue