@@ -738,7 +738,6 @@ static RPCHelpMan getblocktemplate()
738
738
{
739
739
// Wait to respond until either the best block changes, OR a minute has passed and there are more transactions
740
740
uint256 hashWatchedChain;
741
- std::chrono::steady_clock::time_point checktxtime;
742
741
unsigned int nTransactionsUpdatedLastLP;
743
742
744
743
if (lpval.isStr ())
@@ -759,19 +758,14 @@ static RPCHelpMan getblocktemplate()
759
758
// Release lock while waiting
760
759
LEAVE_CRITICAL_SECTION (cs_main);
761
760
{
762
- checktxtime = std::chrono::steady_clock::now () + std::chrono::minutes (1 );
763
-
764
- WAIT_LOCK (g_best_block_mutex, lock);
765
- while (g_best_block == hashWatchedChain && IsRPCRunning ())
766
- {
767
- if (g_best_block_cv.wait_until (lock, checktxtime) == std::cv_status::timeout)
768
- {
769
- // Timeout: Check transactions for update
770
- // without holding the mempool lock to avoid deadlocks
771
- if (miner.getTransactionsUpdated () != nTransactionsUpdatedLastLP)
772
- break ;
773
- checktxtime += std::chrono::seconds (10 );
774
- }
761
+ MillisecondsDouble checktxtime{std::chrono::minutes (1 )};
762
+ while (tip == hashWatchedChain && IsRPCRunning ()) {
763
+ tip = miner.waitTipChanged (hashWatchedChain, checktxtime).hash ;
764
+ // Timeout: Check transactions for update
765
+ // without holding the mempool lock to avoid deadlocks
766
+ if (miner.getTransactionsUpdated () != nTransactionsUpdatedLastLP)
767
+ break ;
768
+ checktxtime = std::chrono::seconds (10 );
775
769
}
776
770
}
777
771
ENTER_CRITICAL_SECTION (cs_main);
0 commit comments