mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Pass oldList and diff instead of newList into NotifyMasternodeListChanged
This commit is contained in:
parent
1ba8694cd7
commit
db781b32dc
@ -81,9 +81,9 @@ void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBl
|
||||
CPrivateSend::SyncTransaction(tx, pindex, posInBlock);
|
||||
}
|
||||
|
||||
void CDSNotificationInterface::NotifyMasternodeListChanged(const CDeterministicMNList& newList)
|
||||
void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff)
|
||||
{
|
||||
CMNAuth::NotifyMasternodeListChanged(newList);
|
||||
CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff);
|
||||
governance.CheckMasternodeOrphanObjects(connman);
|
||||
governance.CheckMasternodeOrphanVotes(connman);
|
||||
governance.UpdateCachesAndClean();
|
||||
|
@ -22,7 +22,7 @@ protected:
|
||||
void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload) override;
|
||||
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
|
||||
void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) override;
|
||||
void NotifyMasternodeListChanged(const CDeterministicMNList& newList) override;
|
||||
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) override;
|
||||
void NotifyChainLock(const CBlockIndex* pindex) override;
|
||||
|
||||
private:
|
||||
|
@ -498,7 +498,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
|
||||
|
||||
// Don't hold cs while calling signals
|
||||
if (!diff.addedMNs.empty() || !diff.removedMns.empty()) {
|
||||
GetMainSignals().NotifyMasternodeListChanged(newList);
|
||||
GetMainSignals().NotifyMasternodeListChanged(false, oldList, diff);
|
||||
}
|
||||
|
||||
const auto& consensusParams = Params().GetConsensus();
|
||||
@ -522,11 +522,19 @@ bool CDeterministicMNManager::UndoBlock(const CBlock& block, const CBlockIndex*
|
||||
int nHeight = pindex->nHeight;
|
||||
uint256 blockHash = block.GetHash();
|
||||
|
||||
CDeterministicMNList curList;
|
||||
CDeterministicMNList prevList;
|
||||
CDeterministicMNListDiff diff;
|
||||
{
|
||||
LOCK(cs);
|
||||
evoDb.Read(std::make_pair(DB_LIST_DIFF, blockHash), diff);
|
||||
|
||||
if (diff.HasChanges()) {
|
||||
// need to call this before erasing
|
||||
curList = GetListForBlock(blockHash);
|
||||
prevList = GetListForBlock(pindex->pprev->GetBlockHash());
|
||||
}
|
||||
|
||||
evoDb.Erase(std::make_pair(DB_LIST_DIFF, blockHash));
|
||||
evoDb.Erase(std::make_pair(DB_LIST_SNAPSHOT, blockHash));
|
||||
|
||||
@ -534,8 +542,8 @@ bool CDeterministicMNManager::UndoBlock(const CBlock& block, const CBlockIndex*
|
||||
}
|
||||
|
||||
if (!diff.addedMNs.empty() || !diff.removedMns.empty()) {
|
||||
auto prevList = GetListForBlock(pindex->pprev->GetBlockHash());
|
||||
GetMainSignals().NotifyMasternodeListChanged(prevList);
|
||||
auto inversedDiff = curList.BuildDiff(prevList);
|
||||
GetMainSignals().NotifyMasternodeListChanged(true, curList, inversedDiff);
|
||||
}
|
||||
|
||||
const auto& consensusParams = Params().GetConsensus();
|
||||
|
@ -30,7 +30,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||
g_signals.NotifyGovernanceObject.connect(boost::bind(&CValidationInterface::NotifyGovernanceObject, pwalletIn, _1));
|
||||
g_signals.NotifyGovernanceVote.connect(boost::bind(&CValidationInterface::NotifyGovernanceVote, pwalletIn, _1));
|
||||
g_signals.NotifyInstantSendDoubleSpendAttempt.connect(boost::bind(&CValidationInterface::NotifyInstantSendDoubleSpendAttempt, pwalletIn, _1, _2));
|
||||
g_signals.NotifyMasternodeListChanged.connect(boost::bind(&CValidationInterface::NotifyMasternodeListChanged, pwalletIn, _1));
|
||||
g_signals.NotifyMasternodeListChanged.connect(boost::bind(&CValidationInterface::NotifyMasternodeListChanged, pwalletIn, _1, _2, _3));
|
||||
}
|
||||
|
||||
void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||
@ -51,7 +51,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||
g_signals.NotifyGovernanceObject.disconnect(boost::bind(&CValidationInterface::NotifyGovernanceObject, pwalletIn, _1));
|
||||
g_signals.NotifyGovernanceVote.disconnect(boost::bind(&CValidationInterface::NotifyGovernanceVote, pwalletIn, _1));
|
||||
g_signals.NotifyInstantSendDoubleSpendAttempt.disconnect(boost::bind(&CValidationInterface::NotifyInstantSendDoubleSpendAttempt, pwalletIn, _1, _2));
|
||||
g_signals.NotifyMasternodeListChanged.disconnect(boost::bind(&CValidationInterface::NotifyMasternodeListChanged, pwalletIn, _1));
|
||||
g_signals.NotifyMasternodeListChanged.disconnect(boost::bind(&CValidationInterface::NotifyMasternodeListChanged, pwalletIn, _1, _2, _3));
|
||||
}
|
||||
|
||||
void UnregisterAllValidationInterfaces() {
|
||||
|
@ -21,6 +21,7 @@ class CValidationState;
|
||||
class CGovernanceVote;
|
||||
class CGovernanceObject;
|
||||
class CDeterministicMNList;
|
||||
class CDeterministicMNListDiff;
|
||||
class uint256;
|
||||
|
||||
// These functions dispatch to one or all registered wallets
|
||||
@ -43,7 +44,7 @@ protected:
|
||||
virtual void NotifyGovernanceVote(const CGovernanceVote &vote) {}
|
||||
virtual void NotifyGovernanceObject(const CGovernanceObject &object) {}
|
||||
virtual void NotifyInstantSendDoubleSpendAttempt(const CTransaction ¤tTx, const CTransaction &previousTx) {}
|
||||
virtual void NotifyMasternodeListChanged(const CDeterministicMNList& newList) {}
|
||||
virtual void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) {}
|
||||
virtual void SetBestChain(const CBlockLocator &locator) {}
|
||||
virtual bool UpdatedTransaction(const uint256 &hash) { return false;}
|
||||
virtual void Inventory(const uint256 &hash) {}
|
||||
@ -86,7 +87,7 @@ struct CMainSignals {
|
||||
/** Notifies listeners of a attempted InstantSend double spend*/
|
||||
boost::signals2::signal<void(const CTransaction ¤tTx, const CTransaction &previousTx)> NotifyInstantSendDoubleSpendAttempt;
|
||||
/** Notifies listeners that the MN list changed */
|
||||
boost::signals2::signal<void(const CDeterministicMNList& newList)> NotifyMasternodeListChanged;
|
||||
boost::signals2::signal<void(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff)> NotifyMasternodeListChanged;
|
||||
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
|
||||
boost::signals2::signal<bool (const uint256 &)> UpdatedTransaction;
|
||||
/** Notifies listeners of a new active block chain. */
|
||||
|
Loading…
Reference in New Issue
Block a user