Update cached incremental witnesses when the active block chain tip changes
This commit is contained in:
parent
be74c80deb
commit
769e031c1a
|
@ -2403,6 +2403,8 @@ bool static DisconnectTip(CValidationState &state) {
|
|||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||
SyncWithWallets(tx, NULL);
|
||||
}
|
||||
// Update cached incremental witnesses
|
||||
GetMainSignals().ChainTip(pindexDelete, &block, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2468,6 +2470,8 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||
BOOST_FOREACH(const CTransaction &tx, pblock->vtx) {
|
||||
SyncWithWallets(tx, pblock);
|
||||
}
|
||||
// Update cached incremental witnesses
|
||||
GetMainSignals().ChainTip(pindexNew, pblock, true);
|
||||
|
||||
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
||||
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
|
||||
|
|
|
@ -16,6 +16,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
|
|||
g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2));
|
||||
g_signals.EraseTransaction.connect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1));
|
||||
g_signals.UpdatedTransaction.connect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
|
||||
g_signals.ChainTip.connect(boost::bind(&CValidationInterface::ChainTip, pwalletIn, _1, _2, _3));
|
||||
g_signals.SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
|
||||
g_signals.Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
|
||||
g_signals.Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1));
|
||||
|
@ -26,6 +27,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
|||
g_signals.BlockChecked.disconnect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2));
|
||||
g_signals.Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1));
|
||||
g_signals.Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1));
|
||||
g_signals.ChainTip.disconnect(boost::bind(&CValidationInterface::ChainTip, pwalletIn, _1, _2, _3));
|
||||
g_signals.SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1));
|
||||
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
|
||||
g_signals.EraseTransaction.disconnect(boost::bind(&CValidationInterface::EraseFromWallet, pwalletIn, _1));
|
||||
|
@ -36,6 +38,7 @@ void UnregisterAllValidationInterfaces() {
|
|||
g_signals.BlockChecked.disconnect_all_slots();
|
||||
g_signals.Broadcast.disconnect_all_slots();
|
||||
g_signals.Inventory.disconnect_all_slots();
|
||||
g_signals.ChainTip.disconnect_all_slots();
|
||||
g_signals.SetBestChain.disconnect_all_slots();
|
||||
g_signals.UpdatedTransaction.disconnect_all_slots();
|
||||
g_signals.EraseTransaction.disconnect_all_slots();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
class CBlock;
|
||||
class CBlockIndex;
|
||||
struct CBlockLocator;
|
||||
class CTransaction;
|
||||
class CValidationInterface;
|
||||
|
@ -30,6 +31,7 @@ class CValidationInterface {
|
|||
protected:
|
||||
virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {}
|
||||
virtual void EraseFromWallet(const uint256 &hash) {}
|
||||
virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, bool added) {}
|
||||
virtual void SetBestChain(const CBlockLocator &locator) {}
|
||||
virtual void UpdatedTransaction(const uint256 &hash) {}
|
||||
virtual void Inventory(const uint256 &hash) {}
|
||||
|
@ -47,6 +49,8 @@ struct CMainSignals {
|
|||
boost::signals2::signal<void (const uint256 &)> EraseTransaction;
|
||||
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
|
||||
boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
|
||||
/** Notifies listeners of a change to the tip of the active block chain. */
|
||||
boost::signals2::signal<void (const CBlockIndex *, const CBlock *, bool)> ChainTip;
|
||||
/** Notifies listeners of a new active block chain. */
|
||||
boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
|
||||
/** Notifies listeners about an inventory item being seen on the network. */
|
||||
|
|
|
@ -336,6 +336,15 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
|||
return false;
|
||||
}
|
||||
|
||||
void CWallet::ChainTip(const CBlockIndex *pindex, const CBlock *pblock, bool added)
|
||||
{
|
||||
if (added) {
|
||||
IncrementNoteWitnesses(pindex, pblock, pcoinsTip);
|
||||
} else {
|
||||
DecrementNoteWitnesses();
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::SetBestChain(const CBlockLocator& loc)
|
||||
{
|
||||
CWalletDB walletdb(strWalletFile);
|
||||
|
|
|
@ -810,6 +810,7 @@ public:
|
|||
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
|
||||
CAmount GetChange(const CTransaction& tx) const;
|
||||
void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, bool added);
|
||||
void SetBestChain(const CBlockLocator& loc);
|
||||
|
||||
DBErrors LoadWallet(bool& fFirstRunRet);
|
||||
|
|
Loading…
Reference in New Issue