aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-07-20 15:29:17 +0200
committerMacroFake <falke.marco@gmail.com>2022-07-20 15:29:21 +0200
commit1eedde157f2e475243ad1e0527309d85f423d6bb (patch)
tree4e64031b99e9fe351cdffb7830c92d9868fbed75 /src/node
parent895937edb2cca3046640dc016827a216e0b6d1c1 (diff)
parentfa32b1bbfd418410c47b2a33c6fa106371288138 (diff)
downloadbitcoin-1eedde157f2e475243ad1e0527309d85f423d6bb.tar.xz
Merge bitcoin/bitcoin#25638: refactor: Use chainman() helper consistently in ChainImpl
fa32b1bbfd418410c47b2a33c6fa106371288138 refactor: Use chainman() helper consistently in ChainImpl (MacroFake) Pull request description: Doing anything else will just lead to more verbose and inconsistent code. ACKs for top commit: fanquake: ACK fa32b1bbfd418410c47b2a33c6fa106371288138 - all instances of `Assert(m_node.chainman)` in node/interfaces replaced with `chainman()`, which is the same thing. shaavan: Code Review ACK fa32b1bbfd418410c47b2a33c6fa106371288138 Tree-SHA512: a417680f79c150e4431aa89bc9db79fdf2dd409419081eb243194837b4ab8d16434165393f39a157473802753843e8c5314ad05c569b4e9221ce29a9fd1cefb8
Diffstat (limited to 'src/node')
-rw-r--r--src/node/interfaces.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 56b5a928ad..be7e3992f0 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -509,7 +509,7 @@ public:
std::optional<int> getHeight() override
{
LOCK(::cs_main);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
+ const CChain& active = chainman().ActiveChain();
int height = active.Height();
if (height >= 0) {
return height;
@@ -519,7 +519,7 @@ public:
uint256 getBlockHash(int height) override
{
LOCK(::cs_main);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
+ const CChain& active = chainman().ActiveChain();
CBlockIndex* block = active[height];
assert(block);
return block->GetBlockHash();
@@ -527,14 +527,14 @@ public:
bool haveBlockOnDisk(int height) override
{
LOCK(::cs_main);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
+ const CChain& active = chainman().ActiveChain();
CBlockIndex* block = active[height];
return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
}
CBlockLocator getTipLocator() override
{
LOCK(::cs_main);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
+ const CChain& active = chainman().ActiveChain();
return active.GetLocator();
}
CBlockLocator getActiveChainLocator(const uint256& block_hash) override
@@ -547,7 +547,7 @@ public:
std::optional<int> findLocatorFork(const CBlockLocator& locator) override
{
LOCK(::cs_main);
- const CChainState& active = Assert(m_node.chainman)->ActiveChainstate();
+ const CChainState& active = chainman().ActiveChainstate();
if (const CBlockIndex* fork = active.FindForkInGlobalIndex(locator)) {
return fork->nHeight;
}
@@ -556,20 +556,20 @@ public:
bool findBlock(const uint256& hash, const FoundBlock& block) override
{
WAIT_LOCK(cs_main, lock);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
- return FillBlock(m_node.chainman->m_blockman.LookupBlockIndex(hash), block, lock, active);
+ const CChain& active = chainman().ActiveChain();
+ return FillBlock(chainman().m_blockman.LookupBlockIndex(hash), block, lock, active);
}
bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock& block) override
{
WAIT_LOCK(cs_main, lock);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
+ const CChain& active = chainman().ActiveChain();
return FillBlock(active.FindEarliestAtLeast(min_time, min_height), block, lock, active);
}
bool findAncestorByHeight(const uint256& block_hash, int ancestor_height, const FoundBlock& ancestor_out) override
{
WAIT_LOCK(cs_main, lock);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
- if (const CBlockIndex* block = m_node.chainman->m_blockman.LookupBlockIndex(block_hash)) {
+ 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);
}
@@ -579,18 +579,18 @@ public:
bool findAncestorByHash(const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override
{
WAIT_LOCK(cs_main, lock);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
- const CBlockIndex* block = m_node.chainman->m_blockman.LookupBlockIndex(block_hash);
- const CBlockIndex* ancestor = m_node.chainman->m_blockman.LookupBlockIndex(ancestor_hash);
+ const CChain& active = chainman().ActiveChain();
+ 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, active);
}
bool findCommonAncestor(const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
{
WAIT_LOCK(cs_main, lock);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
- const CBlockIndex* block1 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash1);
- const CBlockIndex* block2 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash2);
+ const CChain& active = chainman().ActiveChain();
+ const CBlockIndex* block1 = chainman().m_blockman.LookupBlockIndex(block_hash1);
+ const CBlockIndex* block2 = chainman().m_blockman.LookupBlockIndex(block_hash2);
const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
// Using & instead of && below to avoid short circuiting and leaving
// output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
@@ -703,7 +703,7 @@ public:
bool havePruned() override
{
LOCK(::cs_main);
- return m_node.chainman->m_blockman.m_have_pruned;
+ return chainman().m_blockman.m_have_pruned;
}
bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); }
bool isInitialBlockDownload() override {
@@ -725,7 +725,7 @@ public:
{
if (!old_tip.IsNull()) {
LOCK(::cs_main);
- const CChain& active = Assert(m_node.chainman)->ActiveChain();
+ const CChain& active = chainman().ActiveChain();
if (old_tip == active.Tip()->GetBlockHash()) return;
}
SyncWithValidationInterfaceQueue();
@@ -779,7 +779,7 @@ public:
}
bool hasAssumedValidChain() override
{
- return Assert(m_node.chainman)->IsSnapshotActive();
+ return chainman().IsSnapshotActive();
}
NodeContext* context() override { return &m_node; }