@@ -449,13 +449,15 @@ class ChainImpl : public Chain
449
449
bool checkFinalTx (const CTransaction& tx) override
450
450
{
451
451
LOCK (cs_main);
452
- return CheckFinalTx (::ChainActive ().Tip (), tx);
452
+ assert (std::addressof (::ChainActive ()) == std::addressof (m_node.chainman ->ActiveChain ()));
453
+ return CheckFinalTx (m_node.chainman ->ActiveChain ().Tip (), tx);
453
454
}
454
455
Optional<int > findLocatorFork (const CBlockLocator& locator) override
455
456
{
456
457
LOCK (cs_main);
457
458
const CChain& active = Assert (m_node.chainman )->ActiveChain ();
458
- if (CBlockIndex* fork = g_chainman.m_blockman .FindForkInGlobalIndex (active, locator)) {
459
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
460
+ if (CBlockIndex* fork = m_node.chainman ->m_blockman .FindForkInGlobalIndex (active, locator)) {
459
461
return fork->nHeight ;
460
462
}
461
463
return nullopt;
@@ -464,7 +466,8 @@ class ChainImpl : public Chain
464
466
{
465
467
WAIT_LOCK (cs_main, lock);
466
468
const CChain& active = Assert (m_node.chainman )->ActiveChain ();
467
- return FillBlock (g_chainman.m_blockman .LookupBlockIndex (hash), block, lock, active);
469
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
470
+ return FillBlock (m_node.chainman ->m_blockman .LookupBlockIndex (hash), block, lock, active);
468
471
}
469
472
bool findFirstBlockWithTimeAndHeight (int64_t min_time, int min_height, const FoundBlock& block) override
470
473
{
@@ -476,7 +479,8 @@ class ChainImpl : public Chain
476
479
{
477
480
WAIT_LOCK (cs_main, lock);
478
481
const CChain& active = Assert (m_node.chainman )->ActiveChain ();
479
- if (const CBlockIndex* block = g_chainman.m_blockman .LookupBlockIndex (block_hash)) {
482
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
483
+ if (const CBlockIndex* block = m_node.chainman ->m_blockman .LookupBlockIndex (block_hash)) {
480
484
if (const CBlockIndex* ancestor = block->GetAncestor (ancestor_height)) {
481
485
return FillBlock (ancestor, ancestor_out, lock, active);
482
486
}
@@ -487,17 +491,21 @@ class ChainImpl : public Chain
487
491
{
488
492
WAIT_LOCK (cs_main, lock);
489
493
const CChain& active = Assert (m_node.chainman )->ActiveChain ();
490
- const CBlockIndex* block = g_chainman.m_blockman .LookupBlockIndex (block_hash);
491
- const CBlockIndex* ancestor = g_chainman.m_blockman .LookupBlockIndex (ancestor_hash);
494
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
495
+ const CBlockIndex* block = m_node.chainman ->m_blockman .LookupBlockIndex (block_hash);
496
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
497
+ const CBlockIndex* ancestor = m_node.chainman ->m_blockman .LookupBlockIndex (ancestor_hash);
492
498
if (block && ancestor && block->GetAncestor (ancestor->nHeight ) != ancestor) ancestor = nullptr ;
493
499
return FillBlock (ancestor, ancestor_out, lock, active);
494
500
}
495
501
bool findCommonAncestor (const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
496
502
{
497
503
WAIT_LOCK (cs_main, lock);
498
504
const CChain& active = Assert (m_node.chainman )->ActiveChain ();
499
- const CBlockIndex* block1 = g_chainman.m_blockman .LookupBlockIndex (block_hash1);
500
- const CBlockIndex* block2 = g_chainman.m_blockman .LookupBlockIndex (block_hash2);
505
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
506
+ const CBlockIndex* block1 = m_node.chainman ->m_blockman .LookupBlockIndex (block_hash1);
507
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
508
+ const CBlockIndex* block2 = m_node.chainman ->m_blockman .LookupBlockIndex (block_hash2);
501
509
const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor (block1, block2) : nullptr ;
502
510
// Using & instead of && below to avoid short circuiting and leaving
503
511
// output uninitialized.
@@ -507,7 +515,8 @@ class ChainImpl : public Chain
507
515
double guessVerificationProgress (const uint256& block_hash) override
508
516
{
509
517
LOCK (cs_main);
510
- return GuessVerificationProgress (Params ().TxData (), g_chainman.m_blockman .LookupBlockIndex (block_hash));
518
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
519
+ return GuessVerificationProgress (Params ().TxData (), m_node.chainman ->m_blockman .LookupBlockIndex (block_hash));
511
520
}
512
521
bool hasBlocks (const uint256& block_hash, int min_height, Optional<int > max_height) override
513
522
{
@@ -519,7 +528,8 @@ class ChainImpl : public Chain
519
528
// used to limit the range, and passing min_height that's too low or
520
529
// max_height that's too high will not crash or change the result.
521
530
LOCK (::cs_main);
522
- if (CBlockIndex* block = g_chainman.m_blockman .LookupBlockIndex (block_hash)) {
531
+ assert (std::addressof (g_chainman) == std::addressof (*m_node.chainman ));
532
+ if (CBlockIndex* block = m_node.chainman ->m_blockman .LookupBlockIndex (block_hash)) {
523
533
if (max_height && block->nHeight >= *max_height) block = block->GetAncestor (*max_height);
524
534
for (; block->nStatus & BLOCK_HAVE_DATA; block = block->pprev ) {
525
535
// Check pprev to not segfault if min_height is too low
@@ -603,7 +613,10 @@ class ChainImpl : public Chain
603
613
return ::fHavePruned ;
604
614
}
605
615
bool isReadyToBroadcast () override { return !::fImporting && !::fReindex && !isInitialBlockDownload (); }
606
- bool isInitialBlockDownload () override { return ::ChainstateActive ().IsInitialBlockDownload (); }
616
+ bool isInitialBlockDownload () override {
617
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (m_node.chainman ->ActiveChainstate ()));
618
+ return m_node.chainman ->ActiveChainstate ().IsInitialBlockDownload ();
619
+ }
607
620
bool shutdownRequested () override { return ShutdownRequested (); }
608
621
int64_t getAdjustedTime () override { return GetAdjustedTime (); }
609
622
void initMessage (const std::string& message) override { ::uiInterface.InitMessage (message); }
0 commit comments