Skip to content

Commit 7942951

Browse files
ryanofskySjors
authored andcommitted
Remove unused g_best_block
1 parent e3a560c commit 7942951

File tree

4 files changed

+7
-22
lines changed

4 files changed

+7
-22
lines changed

src/rpc/server.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ void StopRPC(const std::any& context)
303303
LogDebug(BCLog::RPC, "Stopping RPC\n");
304304
WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
305305
DeleteAuthCookie();
306-
g_best_block_cv.notify_all();
307306
node::NodeContext& node = EnsureAnyNodeContext(context);
308307
// The notifications interface doesn't exist between initialization step 4a and 7.
309308
if (node.notifications) node.notifications->m_tip_block_cv.notify_all();

src/test/validation_chainstate_tests.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
#include <chainparams.h>
66
#include <consensus/validation.h>
7+
#include <node/kernel_notifications.h>
78
#include <random.h>
89
#include <rpc/blockchain.h>
910
#include <sync.h>
@@ -69,14 +70,14 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
6970
BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
7071
{
7172
ChainstateManager& chainman = *Assert(m_node.chainman);
72-
uint256 curr_tip = ::g_best_block;
73+
uint256 curr_tip = m_node.notifications->m_tip_block;
7374

7475
// Mine 10 more blocks, putting at us height 110 where a valid assumeutxo value can
7576
// be found.
7677
mineBlocks(10);
7778

7879
// After adding some blocks to the tip, best block should have changed.
79-
BOOST_CHECK(::g_best_block != curr_tip);
80+
BOOST_CHECK(m_node.notifications->m_tip_block != curr_tip);
8081

8182
// Grab block 1 from disk; we'll add it to the background chain later.
8283
std::shared_ptr<CBlock> pblockone = std::make_shared<CBlock>();
@@ -91,15 +92,15 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
9192
// Ensure our active chain is the snapshot chainstate.
9293
BOOST_CHECK(WITH_LOCK(::cs_main, return chainman.IsSnapshotActive()));
9394

94-
curr_tip = ::g_best_block;
95+
curr_tip = m_node.notifications->m_tip_block;
9596

9697
// Mine a new block on top of the activated snapshot chainstate.
9798
mineBlocks(1); // Defined in TestChain100Setup.
9899

99100
// After adding some blocks to the snapshot tip, best block should have changed.
100-
BOOST_CHECK(::g_best_block != curr_tip);
101+
BOOST_CHECK(m_node.notifications->m_tip_block != curr_tip);
101102

102-
curr_tip = ::g_best_block;
103+
curr_tip = m_node.notifications->m_tip_block;
103104

104105
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 2);
105106

@@ -138,7 +139,7 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
138139
// g_best_block should be unchanged after adding a block to the background
139140
// validation chain.
140141
BOOST_CHECK(block_added);
141-
BOOST_CHECK_EQUAL(curr_tip, ::g_best_block);
142+
BOOST_CHECK_EQUAL(curr_tip, m_node.notifications->m_tip_block);
142143
}
143144

144145
BOOST_AUTO_TEST_SUITE_END()

src/validation.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ const std::vector<std::string> CHECKLEVEL_DOC {
108108
* */
109109
static constexpr int PRUNE_LOCK_BUFFER{10};
110110

111-
GlobalMutex g_best_block_mutex;
112-
std::condition_variable g_best_block_cv;
113-
uint256 g_best_block;
114-
115111
const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const
116112
{
117113
AssertLockHeld(cs_main);
@@ -2988,12 +2984,6 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
29882984
m_mempool->AddTransactionsUpdated(1);
29892985
}
29902986

2991-
{
2992-
LOCK(g_best_block_mutex);
2993-
g_best_block = pindexNew->GetBlockHash();
2994-
g_best_block_cv.notify_all();
2995-
}
2996-
29972987
std::vector<bilingual_str> warning_messages;
29982988
if (!m_chainman.IsInitialBlockDownload()) {
29992989
const CBlockIndex* pindex = pindexNew;

src/validation.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ enum class SynchronizationState {
8585
POST_INIT
8686
};
8787

88-
extern GlobalMutex g_best_block_mutex;
89-
extern std::condition_variable g_best_block_cv;
90-
/** Used to notify getblocktemplate RPC of new tips. */
91-
extern uint256 g_best_block;
92-
9388
/** Documentation for argument 'checklevel'. */
9489
extern const std::vector<std::string> CHECKLEVEL_DOC;
9590

0 commit comments

Comments
 (0)