From e170c3abd6e4ea448d37b08819ed94b4ed822eba Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Tue, 1 Mar 2022 17:43:43 -0700 Subject: [PATCH] document global variables --- src/main.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.h b/src/main.h index b5c8ba90c..da065f63a 100644 --- a/src/main.h +++ b/src/main.h @@ -161,11 +161,17 @@ extern std::optional last_block_num_txs; extern std::optional last_block_size; extern const std::string strMessageMagic; -// These prevent lock-ordering problems in getblocktemplate() RPC +//! These four variables are used to notify getblocktemplate RPC of new tips. +//! When UpdateTip() establishes a new tip (best block), it must awaken a +//! waiting getblocktemplate RPC (if there is one) immediately. But upon waking +//! up, getblocktemplate cannot call chainActive->Tip() because it does not +//! (and cannot) hold cs_main. So the g_best_block_height and g_best_block variables +//! (protected by g_best_block_mutex) provide the needed height and block +//! hash respectively to getblocktemplate without it requiring cs_main. extern CWaitableCriticalSection g_best_block_mutex; extern CConditionVariable g_best_block_cv; -extern uint256 g_best_block; extern int g_best_block_height; +extern uint256 g_best_block; extern std::atomic_bool fImporting; extern std::atomic_bool fReindex;