@@ -509,7 +509,7 @@ class ChainImpl : public Chain
509509 std::optional<int > getHeight () override
510510 {
511511 LOCK (::cs_main);
512- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
512+ const CChain& active = chainman (). ActiveChain ();
513513 int height = active.Height ();
514514 if (height >= 0 ) {
515515 return height;
@@ -519,22 +519,22 @@ class ChainImpl : public Chain
519519 uint256 getBlockHash (int height) override
520520 {
521521 LOCK (::cs_main);
522- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
522+ const CChain& active = chainman (). ActiveChain ();
523523 CBlockIndex* block = active[height];
524524 assert (block);
525525 return block->GetBlockHash ();
526526 }
527527 bool haveBlockOnDisk (int height) override
528528 {
529529 LOCK (::cs_main);
530- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
530+ const CChain& active = chainman (). ActiveChain ();
531531 CBlockIndex* block = active[height];
532532 return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0 ) && block->nTx > 0 ;
533533 }
534534 CBlockLocator getTipLocator () override
535535 {
536536 LOCK (::cs_main);
537- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
537+ const CChain& active = chainman (). ActiveChain ();
538538 return active.GetLocator ();
539539 }
540540 CBlockLocator getActiveChainLocator (const uint256& block_hash) override
@@ -547,7 +547,7 @@ class ChainImpl : public Chain
547547 std::optional<int > findLocatorFork (const CBlockLocator& locator) override
548548 {
549549 LOCK (::cs_main);
550- const CChainState& active = Assert (m_node. chainman )-> ActiveChainstate ();
550+ const CChainState& active = chainman (). ActiveChainstate ();
551551 if (const CBlockIndex* fork = active.FindForkInGlobalIndex (locator)) {
552552 return fork->nHeight ;
553553 }
@@ -556,20 +556,20 @@ class ChainImpl : public Chain
556556 bool findBlock (const uint256& hash, const FoundBlock& block) override
557557 {
558558 WAIT_LOCK (cs_main, lock);
559- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
560- return FillBlock (m_node. chainman -> m_blockman .LookupBlockIndex (hash), block, lock, active);
559+ const CChain& active = chainman (). ActiveChain ();
560+ return FillBlock (chainman (). m_blockman .LookupBlockIndex (hash), block, lock, active);
561561 }
562562 bool findFirstBlockWithTimeAndHeight (int64_t min_time, int min_height, const FoundBlock& block) override
563563 {
564564 WAIT_LOCK (cs_main, lock);
565- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
565+ const CChain& active = chainman (). ActiveChain ();
566566 return FillBlock (active.FindEarliestAtLeast (min_time, min_height), block, lock, active);
567567 }
568568 bool findAncestorByHeight (const uint256& block_hash, int ancestor_height, const FoundBlock& ancestor_out) override
569569 {
570570 WAIT_LOCK (cs_main, lock);
571- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
572- if (const CBlockIndex* block = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash)) {
571+ const CChain& active = chainman (). ActiveChain ();
572+ if (const CBlockIndex* block = chainman (). m_blockman .LookupBlockIndex (block_hash)) {
573573 if (const CBlockIndex* ancestor = block->GetAncestor (ancestor_height)) {
574574 return FillBlock (ancestor, ancestor_out, lock, active);
575575 }
@@ -579,18 +579,18 @@ class ChainImpl : public Chain
579579 bool findAncestorByHash (const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override
580580 {
581581 WAIT_LOCK (cs_main, lock);
582- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
583- const CBlockIndex* block = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash);
584- const CBlockIndex* ancestor = m_node. chainman -> m_blockman .LookupBlockIndex (ancestor_hash);
582+ const CChain& active = chainman (). ActiveChain ();
583+ const CBlockIndex* block = chainman (). m_blockman .LookupBlockIndex (block_hash);
584+ const CBlockIndex* ancestor = chainman (). m_blockman .LookupBlockIndex (ancestor_hash);
585585 if (block && ancestor && block->GetAncestor (ancestor->nHeight ) != ancestor) ancestor = nullptr ;
586586 return FillBlock (ancestor, ancestor_out, lock, active);
587587 }
588588 bool findCommonAncestor (const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
589589 {
590590 WAIT_LOCK (cs_main, lock);
591- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
592- const CBlockIndex* block1 = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash1);
593- const CBlockIndex* block2 = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash2);
591+ const CChain& active = chainman (). ActiveChain ();
592+ const CBlockIndex* block1 = chainman (). m_blockman .LookupBlockIndex (block_hash1);
593+ const CBlockIndex* block2 = chainman (). m_blockman .LookupBlockIndex (block_hash2);
594594 const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor (block1, block2) : nullptr ;
595595 // Using & instead of && below to avoid short circuiting and leaving
596596 // output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
@@ -703,7 +703,7 @@ class ChainImpl : public Chain
703703 bool havePruned () override
704704 {
705705 LOCK (::cs_main);
706- return m_node. chainman -> m_blockman .m_have_pruned ;
706+ return chainman (). m_blockman .m_have_pruned ;
707707 }
708708 bool isReadyToBroadcast () override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload (); }
709709 bool isInitialBlockDownload () override {
@@ -725,7 +725,7 @@ class ChainImpl : public Chain
725725 {
726726 if (!old_tip.IsNull ()) {
727727 LOCK (::cs_main);
728- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
728+ const CChain& active = chainman (). ActiveChain ();
729729 if (old_tip == active.Tip ()->GetBlockHash ()) return ;
730730 }
731731 SyncWithValidationInterfaceQueue ();
@@ -779,7 +779,7 @@ class ChainImpl : public Chain
779779 }
780780 bool hasAssumedValidChain () override
781781 {
782- return Assert (m_node. chainman )-> IsSnapshotActive ();
782+ return chainman (). IsSnapshotActive ();
783783 }
784784
785785 NodeContext* context () override { return &m_node; }
0 commit comments