mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
wallet: Remove chainStateFlushed
chainStateFlushed is no longer needed since the best block is updated after a block is scanned. Since the chainstate being flushed does not necessarily coincide with the wallet having processed said block, it does not entirely make sense for the wallet to be recording that block as its best block, and this can cause race conditions where some blocks are not processed. Thus, remove this notification.
This commit is contained in:
parent
151c733c16
commit
d4c7013bec
2 changed files with 0 additions and 18 deletions
|
@ -642,15 +642,6 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::chainStateFlushed(ChainstateRole role, const CBlockLocator& loc)
|
|
||||||
{
|
|
||||||
// Don't update the best block until the chain is attached so that in case of a shutdown,
|
|
||||||
// the rescan will be restarted at next startup.
|
|
||||||
if (m_attaching_chain || role == ChainstateRole::BACKGROUND) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CWallet::SetBestBlock(int block_height, uint256 block_hash)
|
void CWallet::SetBestBlock(int block_height, uint256 block_hash)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
|
@ -3279,11 +3270,6 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
|
||||||
// be pending on the validation-side until lock release. It's likely to have
|
// be pending on the validation-side until lock release. It's likely to have
|
||||||
// block processing duplicata (if rescan block range overlaps with notification one)
|
// block processing duplicata (if rescan block range overlaps with notification one)
|
||||||
// but we guarantee at least than wallet state is correct after notifications delivery.
|
// but we guarantee at least than wallet state is correct after notifications delivery.
|
||||||
// However, chainStateFlushed notifications are ignored until the rescan is finished
|
|
||||||
// so that in case of a shutdown event, the rescan will be repeated at the next start.
|
|
||||||
// This is temporary until rescan and notifications delivery are unified under same
|
|
||||||
// interface.
|
|
||||||
walletInstance->m_attaching_chain = true; //ignores chainStateFlushed notifications
|
|
||||||
walletInstance->m_chain_notifications_handler = walletInstance->chain().handleNotifications(walletInstance);
|
walletInstance->m_chain_notifications_handler = walletInstance->chain().handleNotifications(walletInstance);
|
||||||
|
|
||||||
const std::optional<int> tip_height = chain.getHeight();
|
const std::optional<int> tip_height = chain.getHeight();
|
||||||
|
@ -3371,13 +3357,11 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
|
||||||
error = _("Failed to rescan the wallet during initialization");
|
error = _("Failed to rescan the wallet during initialization");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
walletInstance->m_attaching_chain = false;
|
|
||||||
// Set and update the best block record
|
// Set and update the best block record
|
||||||
walletInstance->SetBestBlock(*scan_res.last_scanned_height, scan_res.last_scanned_block);
|
walletInstance->SetBestBlock(*scan_res.last_scanned_height, scan_res.last_scanned_block);
|
||||||
}
|
}
|
||||||
walletInstance->GetDatabase().IncrementUpdateCounter();
|
walletInstance->GetDatabase().IncrementUpdateCounter();
|
||||||
}
|
}
|
||||||
walletInstance->m_attaching_chain = false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,6 @@ private:
|
||||||
|
|
||||||
std::atomic<bool> fAbortRescan{false};
|
std::atomic<bool> fAbortRescan{false};
|
||||||
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
|
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
|
||||||
std::atomic<bool> m_attaching_chain{false};
|
|
||||||
std::atomic<bool> m_scanning_with_passphrase{false};
|
std::atomic<bool> m_scanning_with_passphrase{false};
|
||||||
std::atomic<SteadyClock::time_point> m_scanning_start{SteadyClock::time_point{}};
|
std::atomic<SteadyClock::time_point> m_scanning_start{SteadyClock::time_point{}};
|
||||||
std::atomic<double> m_scanning_progress{0};
|
std::atomic<double> m_scanning_progress{0};
|
||||||
|
@ -812,7 +811,6 @@ public:
|
||||||
/** should probably be renamed to IsRelevantToMe */
|
/** should probably be renamed to IsRelevantToMe */
|
||||||
bool IsFromMe(const CTransaction& tx) const;
|
bool IsFromMe(const CTransaction& tx) const;
|
||||||
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
|
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
|
||||||
void chainStateFlushed(ChainstateRole role, const CBlockLocator& loc) override;
|
|
||||||
|
|
||||||
DBErrors LoadWallet();
|
DBErrors LoadWallet();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue