mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
![Ryan Ofsky](/assets/img/avatar_default.png)
This change makes IsInitialBlockDownload and NotifyHeaderTip functions no longer tied to individual Chainstate objects. It makes them work with the ChainstateManager object instead so code is simpler and it is no longer possible to call them incorrectly with an inactive Chainstate. This change also makes m_cached_finished_ibd caching easier to reason about, because now there is only one cached value instead of two (for background and snapshot chainstates) so the cached IBD state now no longer gets reset when a snapshot is loaded. There should be no change in behavior because these functions were always called on the active ChainState objects. These changes were discussed previously https://github.com/bitcoin/bitcoin/pull/27746#discussion_r1246868905 and https://github.com/bitcoin/bitcoin/pull/27746#discussion_r1237552792 as possible followups for that PR.
28 lines
797 B
C++
28 lines
797 B
C++
// Copyright (c) 2020-2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <test/util/validation.h>
|
|
|
|
#include <util/check.h>
|
|
#include <util/time.h>
|
|
#include <validation.h>
|
|
#include <validationinterface.h>
|
|
|
|
void TestChainstateManager::ResetIbd()
|
|
{
|
|
m_cached_finished_ibd = false;
|
|
assert(IsInitialBlockDownload());
|
|
}
|
|
|
|
void TestChainstateManager::JumpOutOfIbd()
|
|
{
|
|
Assert(IsInitialBlockDownload());
|
|
m_cached_finished_ibd = true;
|
|
Assert(!IsInitialBlockDownload());
|
|
}
|
|
|
|
void ValidationInterfaceTest::BlockConnected(CValidationInterface& obj, const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
|
|
{
|
|
obj.BlockConnected(block, pindex);
|
|
}
|