@@ -507,7 +507,7 @@ class ChainImpl : public Chain
507507 std::optional<int > getHeight () override
508508 {
509509 LOCK (::cs_main);
510- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
510+ const CChain& active = chainman (). ActiveChain ();
511511 int height = active.Height ();
512512 if (height >= 0 ) {
513513 return height;
@@ -517,22 +517,22 @@ class ChainImpl : public Chain
517517 uint256 getBlockHash (int height) override
518518 {
519519 LOCK (::cs_main);
520- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
520+ const CChain& active = chainman (). ActiveChain ();
521521 CBlockIndex* block = active[height];
522522 assert (block);
523523 return block->GetBlockHash ();
524524 }
525525 bool haveBlockOnDisk (int height) override
526526 {
527527 LOCK (::cs_main);
528- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
528+ const CChain& active = chainman (). ActiveChain ();
529529 CBlockIndex* block = active[height];
530530 return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0 ) && block->nTx > 0 ;
531531 }
532532 CBlockLocator getTipLocator () override
533533 {
534534 LOCK (::cs_main);
535- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
535+ const CChain& active = chainman (). ActiveChain ();
536536 return active.GetLocator ();
537537 }
538538 CBlockLocator getActiveChainLocator (const uint256& block_hash) override
@@ -545,7 +545,7 @@ class ChainImpl : public Chain
545545 std::optional<int > findLocatorFork (const CBlockLocator& locator) override
546546 {
547547 LOCK (::cs_main);
548- const CChainState& active = Assert (m_node. chainman )-> ActiveChainstate ();
548+ const CChainState& active = chainman (). ActiveChainstate ();
549549 if (const CBlockIndex* fork = active.FindForkInGlobalIndex (locator)) {
550550 return fork->nHeight ;
551551 }
@@ -554,20 +554,20 @@ class ChainImpl : public Chain
554554 bool findBlock (const uint256& hash, const FoundBlock& block) override
555555 {
556556 WAIT_LOCK (cs_main, lock);
557- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
558- return FillBlock (m_node. chainman -> m_blockman .LookupBlockIndex (hash), block, lock, active);
557+ const CChain& active = chainman (). ActiveChain ();
558+ return FillBlock (chainman (). m_blockman .LookupBlockIndex (hash), block, lock, active);
559559 }
560560 bool findFirstBlockWithTimeAndHeight (int64_t min_time, int min_height, const FoundBlock& block) override
561561 {
562562 WAIT_LOCK (cs_main, lock);
563- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
563+ const CChain& active = chainman (). ActiveChain ();
564564 return FillBlock (active.FindEarliestAtLeast (min_time, min_height), block, lock, active);
565565 }
566566 bool findAncestorByHeight (const uint256& block_hash, int ancestor_height, const FoundBlock& ancestor_out) override
567567 {
568568 WAIT_LOCK (cs_main, lock);
569- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
570- if (const CBlockIndex* block = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash)) {
569+ const CChain& active = chainman (). ActiveChain ();
570+ if (const CBlockIndex* block = chainman (). m_blockman .LookupBlockIndex (block_hash)) {
571571 if (const CBlockIndex* ancestor = block->GetAncestor (ancestor_height)) {
572572 return FillBlock (ancestor, ancestor_out, lock, active);
573573 }
@@ -577,18 +577,18 @@ class ChainImpl : public Chain
577577 bool findAncestorByHash (const uint256& block_hash, const uint256& ancestor_hash, const FoundBlock& ancestor_out) override
578578 {
579579 WAIT_LOCK (cs_main, lock);
580- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
581- const CBlockIndex* block = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash);
582- const CBlockIndex* ancestor = m_node. chainman -> m_blockman .LookupBlockIndex (ancestor_hash);
580+ const CChain& active = chainman (). ActiveChain ();
581+ const CBlockIndex* block = chainman (). m_blockman .LookupBlockIndex (block_hash);
582+ const CBlockIndex* ancestor = chainman (). m_blockman .LookupBlockIndex (ancestor_hash);
583583 if (block && ancestor && block->GetAncestor (ancestor->nHeight ) != ancestor) ancestor = nullptr ;
584584 return FillBlock (ancestor, ancestor_out, lock, active);
585585 }
586586 bool findCommonAncestor (const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
587587 {
588588 WAIT_LOCK (cs_main, lock);
589- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
590- const CBlockIndex* block1 = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash1);
591- const CBlockIndex* block2 = m_node. chainman -> m_blockman .LookupBlockIndex (block_hash2);
589+ const CChain& active = chainman (). ActiveChain ();
590+ const CBlockIndex* block1 = chainman (). m_blockman .LookupBlockIndex (block_hash1);
591+ const CBlockIndex* block2 = chainman (). m_blockman .LookupBlockIndex (block_hash2);
592592 const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor (block1, block2) : nullptr ;
593593 // Using & instead of && below to avoid short circuiting and leaving
594594 // output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
@@ -701,7 +701,7 @@ class ChainImpl : public Chain
701701 bool havePruned () override
702702 {
703703 LOCK (::cs_main);
704- return m_node. chainman -> m_blockman .m_have_pruned ;
704+ return chainman (). m_blockman .m_have_pruned ;
705705 }
706706 bool isReadyToBroadcast () override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload (); }
707707 bool isInitialBlockDownload () override {
@@ -723,7 +723,7 @@ class ChainImpl : public Chain
723723 {
724724 if (!old_tip.IsNull ()) {
725725 LOCK (::cs_main);
726- const CChain& active = Assert (m_node. chainman )-> ActiveChain ();
726+ const CChain& active = chainman (). ActiveChain ();
727727 if (old_tip == active.Tip ()->GetBlockHash ()) return ;
728728 }
729729 SyncWithValidationInterfaceQueue ();
@@ -777,7 +777,7 @@ class ChainImpl : public Chain
777777 }
778778 bool hasAssumedValidChain () override
779779 {
780- return Assert (m_node. chainman )-> IsSnapshotActive ();
780+ return chainman (). IsSnapshotActive ();
781781 }
782782
783783 NodeContext& m_node;
0 commit comments