diff options
author | Pieter Wuille <pieter@wuille.net> | 2022-08-07 20:56:17 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2022-08-23 16:05:00 -0400 |
commit | ed470940cddbeb40425960d51cefeec4948febe4 (patch) | |
tree | 91f598eec25c5714404c3c085a0e3d98be9cb73c /src/node/interfaces.cpp | |
parent | 84852bb6bb3579e475ce78fe729fd125ddbc715f (diff) |
Add functions to construct locators without CChain
This introduces an insignificant performance penalty, as it means locator
construction needs to use the skiplist-based CBlockIndex::GetAncestor()
function instead of the lookup-based CChain, but avoids the need for
callers to have access to a relevant CChain object.
Diffstat (limited to 'src/node/interfaces.cpp')
-rw-r--r-- | src/node/interfaces.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 2c845d0127..25161d2cd3 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -400,7 +400,7 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec if (block.m_max_time) *block.m_max_time = index->GetBlockTimeMax(); 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 = active.GetLocator(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_data) { REVERSE_LOCK(lock); @@ -527,8 +527,7 @@ public: { LOCK(::cs_main); const CBlockIndex* index = chainman().m_blockman.LookupBlockIndex(block_hash); - if (!index) return {}; - return chainman().ActiveChain().GetLocator(index); + return GetLocator(index); } std::optional<int> findLocatorFork(const CBlockLocator& locator) override { |