mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #15842: refactor: replace isPotentialtip/waitForNotifications by higher method
422677963arefactor: replace isPotentialtip/waitForNotifications by higher method (Antoine Riard)edfe9438caAdd WITH_LOCK macro: run code while locking a mutex (Antoine Riard) Pull request description: In Chain interface, instead of a isPotentialTip and a WaitForNotifications method, both used only once in CWallet::BlockUntilSyncedToCurrentChain, combine them in a higher WaitForNotificationsUpToTip method. Semantic should be unchanged, wallet wait for pending notifications to be processed unless block hash points to the current chain tip or a descendant. ACKs for commit 422677: jnewbery: ACK422677963aryanofsky: utACK422677963a. Only change is adding the cs_wallet lock annotation. Tree-SHA512: 2834ff0218795ef607543fae822e5cce25d759c1a9cfcb1f896a4af03071faed5276fbe0966e0c6ed65dc0e88af161899c5b2ca358a2d24fe70969a550000bf2
This commit is contained in:
@@ -1287,24 +1287,12 @@ void CWallet::UpdatedBlockTip()
|
||||
|
||||
void CWallet::BlockUntilSyncedToCurrentChain() {
|
||||
AssertLockNotHeld(cs_wallet);
|
||||
|
||||
{
|
||||
// Skip the queue-draining stuff if we know we're caught up with
|
||||
// chainActive.Tip()...
|
||||
// We could also take cs_wallet here, and call m_last_block_processed
|
||||
// protected by cs_wallet instead of cs_main, but as long as we need
|
||||
// cs_main here anyway, it's easier to just call it cs_main-protected.
|
||||
auto locked_chain = chain().lock();
|
||||
|
||||
if (!m_last_block_processed.IsNull() && locked_chain->isPotentialTip(m_last_block_processed)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ...otherwise put a callback in the validation interface queue and wait
|
||||
// Skip the queue-draining stuff if we know we're caught up with
|
||||
// chainActive.Tip(), otherwise put a callback in the validation interface queue and wait
|
||||
// for the queue to drain enough to execute it (indicating we are caught up
|
||||
// at least with the time we entered this function).
|
||||
chain().waitForNotifications();
|
||||
uint256 last_block_hash = WITH_LOCK(cs_wallet, return m_last_block_processed);
|
||||
chain().waitForNotificationsIfNewBlocksConnected(last_block_hash);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user