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.
|
//! pruned), and contains transactions.
|
||||||
virtual bool haveBlockOnDisk(int height) = 0;
|
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,
|
//! 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,
|
//! which will either be the original block used to create the locator,
|
||||||
//! or one of its ancestors.
|
//! or one of its ancestors.
|
||||||
|
@ -323,7 +316,7 @@ public:
|
||||||
virtual void blockConnected(ChainstateRole role, const BlockInfo& block) {}
|
virtual void blockConnected(ChainstateRole role, const BlockInfo& block) {}
|
||||||
virtual void blockDisconnected(const BlockInfo& block) {}
|
virtual void blockDisconnected(const BlockInfo& block) {}
|
||||||
virtual void updatedBlockTip() {}
|
virtual void updatedBlockTip() {}
|
||||||
virtual void chainStateFlushed(ChainstateRole role, const CBlockLocator& locator) {}
|
virtual void chainStateFlushed(ChainstateRole role) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Register handler for notifications.
|
//! Register handler for notifications.
|
||||||
|
|
|
@ -476,7 +476,7 @@ public:
|
||||||
m_notifications->updatedBlockTip();
|
m_notifications->updatedBlockTip();
|
||||||
}
|
}
|
||||||
void ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator) override {
|
void ChainStateFlushed(ChainstateRole role, const CBlockLocator& locator) override {
|
||||||
m_notifications->chainStateFlushed(role, locator);
|
m_notifications->chainStateFlushed(role);
|
||||||
}
|
}
|
||||||
std::shared_ptr<Chain::Notifications> m_notifications;
|
std::shared_ptr<Chain::Notifications> m_notifications;
|
||||||
};
|
};
|
||||||
|
@ -560,17 +560,6 @@ public:
|
||||||
const CBlockIndex* block{chainman().ActiveChain()[height]};
|
const CBlockIndex* block{chainman().ActiveChain()[height]};
|
||||||
return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
|
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
|
std::optional<int> findLocatorFork(const CBlockLocator& locator) override
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
|
|
|
@ -648,15 +648,19 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
||||||
return false;
|
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,
|
// 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.
|
// the rescan will be restarted at next startup.
|
||||||
if (m_attaching_chain || role == ChainstateRole::BACKGROUND) {
|
if (m_attaching_chain || role == ChainstateRole::BACKGROUND) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WalletBatch batch(GetDatabase());
|
CBlockLocator loc;
|
||||||
batch.WriteBestBlock(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)
|
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;
|
result.last_scanned_height = block_height;
|
||||||
|
|
||||||
if (save_progress && next_interval) {
|
if (save_progress && next_interval) {
|
||||||
CBlockLocator loc = m_chain->getActiveChainLocator(block_hash);
|
CBlockLocator loc;
|
||||||
|
chain().findBlock(block_hash, FoundBlock().locator(loc));
|
||||||
if (!loc.IsNull()) {
|
if (!loc.IsNull()) {
|
||||||
WalletLogPrintf("Saving scan progress %d.\n", block_height);
|
WalletLogPrintf("Saving scan progress %d.\n", block_height);
|
||||||
WalletBatch batch(GetDatabase());
|
WalletBatch batch(GetDatabase());
|
||||||
|
@ -3077,7 +3081,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chain) {
|
if (chain) {
|
||||||
walletInstance->chainStateFlushed(ChainstateRole::NORMAL, chain->getTipLocator());
|
walletInstance->chainStateFlushed(ChainstateRole::NORMAL);
|
||||||
}
|
}
|
||||||
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
|
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
|
||||||
// Make it impossible to disable private keys after creation
|
// 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->m_attaching_chain = false;
|
||||||
walletInstance->chainStateFlushed(ChainstateRole::NORMAL, chain.getTipLocator());
|
walletInstance->chainStateFlushed(ChainstateRole::NORMAL);
|
||||||
walletInstance->GetDatabase().IncrementUpdateCounter();
|
walletInstance->GetDatabase().IncrementUpdateCounter();
|
||||||
}
|
}
|
||||||
walletInstance->m_attaching_chain = false;
|
walletInstance->m_attaching_chain = false;
|
||||||
|
|
|
@ -788,7 +788,7 @@ 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;
|
void chainStateFlushed(ChainstateRole role) override;
|
||||||
|
|
||||||
DBErrors LoadWallet();
|
DBErrors LoadWallet();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue