mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-01 09:35:52 -05:00
Merge 560063156a
into 85f96b01b7
This commit is contained in:
commit
85e55982b7
4 changed files with 14 additions and 28 deletions
|
@ -142,13 +142,6 @@ public:
|
|||
//! pruned), and contains transactions.
|
||||
virtual bool haveBlockOnDisk(int height) = 0;
|
||||
|
||||
//! Get locator for the current chain tip.
|
||||
virtual CBlockLocator getTipLocator() = 0;
|
||||
|
||||
//! Return a locator that refers to a block in the active chain.
|
||||
//! If specified block is not in the active chain, return locator for the latest ancestor that is in the chain.
|
||||
virtual CBlockLocator getActiveChainLocator(const uint256& block_hash) = 0;
|
||||
|
||||
//! Return height of the highest block on chain in common with the locator,
|
||||
//! which will either be the original block used to create the locator,
|
||||
//! or one of its ancestors.
|
||||
|
@ -323,7 +316,7 @@ public:
|
|||
virtual void blockConnected(ChainstateRole role, const BlockInfo& block) {}
|
||||
virtual void blockDisconnected(const BlockInfo& block) {}
|
||||
virtual void updatedBlockTip() {}
|
||||
virtual void chainStateFlushed(ChainstateRole role, const CBlockLocator& locator) {}
|
||||
virtual void chainStateFlushed(ChainstateRole role) {}
|
||||
};
|
||||
|
||||
//! Register handler for notifications.
|
||||
|
|
|
@ -476,7 +476,7 @@ public:
|
|||
m_notifications->updatedBlockTip();
|
||||
}
|
||||
void ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator) override {
|
||||
m_notifications->chainStateFlushed(role, locator);
|
||||
m_notifications->chainStateFlushed(role);
|
||||
}
|
||||
std::shared_ptr<Chain::Notifications> m_notifications;
|
||||
};
|
||||
|
@ -560,17 +560,6 @@ public:
|
|||
const CBlockIndex* block{chainman().ActiveChain()[height]};
|
||||
return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
|
||||
}
|
||||
CBlockLocator getTipLocator() override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
return chainman().ActiveChain().GetLocator();
|
||||
}
|
||||
CBlockLocator getActiveChainLocator(const uint256& block_hash) override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
const CBlockIndex* index = chainman().m_blockman.LookupBlockIndex(block_hash);
|
||||
return GetLocator(index);
|
||||
}
|
||||
std::optional<int> findLocatorFork(const CBlockLocator& locator) override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
|
|
|
@ -648,15 +648,19 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
|||
return false;
|
||||
}
|
||||
|
||||
void CWallet::chainStateFlushed(ChainstateRole role, const CBlockLocator& loc)
|
||||
void CWallet::chainStateFlushed(ChainstateRole role)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
CBlockLocator loc;
|
||||
WITH_LOCK(cs_wallet, chain().findBlock(m_last_block_processed, FoundBlock().locator(loc)));
|
||||
if (!loc.IsNull()) {
|
||||
WalletBatch batch(GetDatabase());
|
||||
batch.WriteBestBlock(loc);
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in)
|
||||
|
@ -1973,8 +1977,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
|||
result.last_scanned_height = block_height;
|
||||
|
||||
if (save_progress && next_interval) {
|
||||
CBlockLocator loc = m_chain->getActiveChainLocator(block_hash);
|
||||
|
||||
CBlockLocator loc;
|
||||
chain().findBlock(block_hash, FoundBlock().locator(loc));
|
||||
if (!loc.IsNull()) {
|
||||
WalletLogPrintf("Saving scan progress %d.\n", block_height);
|
||||
WalletBatch batch(GetDatabase());
|
||||
|
@ -3077,7 +3081,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
}
|
||||
|
||||
if (chain) {
|
||||
walletInstance->chainStateFlushed(ChainstateRole::NORMAL, chain->getTipLocator());
|
||||
walletInstance->chainStateFlushed(ChainstateRole::NORMAL);
|
||||
}
|
||||
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
|
||||
// Make it impossible to disable private keys after creation
|
||||
|
@ -3364,7 +3368,7 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
|
|||
}
|
||||
}
|
||||
walletInstance->m_attaching_chain = false;
|
||||
walletInstance->chainStateFlushed(ChainstateRole::NORMAL, chain.getTipLocator());
|
||||
walletInstance->chainStateFlushed(ChainstateRole::NORMAL);
|
||||
walletInstance->GetDatabase().IncrementUpdateCounter();
|
||||
}
|
||||
walletInstance->m_attaching_chain = false;
|
||||
|
|
|
@ -788,7 +788,7 @@ public:
|
|||
/** should probably be renamed to IsRelevantToMe */
|
||||
bool IsFromMe(const CTransaction& tx) const;
|
||||
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
void chainStateFlushed(ChainstateRole role, const CBlockLocator& loc) override;
|
||||
void chainStateFlushed(ChainstateRole role) override;
|
||||
|
||||
DBErrors LoadWallet();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue