Skip to content

Commit

Permalink
CValidationInterface: ValidationInterfaceUnregistering, called when b…
Browse files Browse the repository at this point in the history
…eing unregistered
  • Loading branch information
luke-jr committed Nov 21, 2020
1 parent 831675c commit 47711fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/validationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ void UnregisterSharedValidationInterface(std::shared_ptr<CValidationInterface> c

void UnregisterValidationInterface(CValidationInterface* callbacks)
{
callbacks->ValidationInterfaceUnregistering();

if (g_signals.m_internals) {
g_signals.m_internals->Unregister(callbacks);
}
Expand All @@ -149,6 +151,9 @@ void UnregisterAllValidationInterfaces()
if (!g_signals.m_internals) {
return;
}

g_signals.m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.ValidationInterfaceUnregistering(); });

g_signals.m_internals->Clear();
}

Expand Down
7 changes: 7 additions & 0 deletions src/validationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,14 @@ class CValidationInterface {
* Notifies listeners that a block which builds directly on our current tip
* has been received and connected to the headers tree, though not validated yet */
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
/**
* Notifies the validation interface that it is being unregistered
*/
virtual void ValidationInterfaceUnregistering() {};

friend class CMainSignals;
friend void UnregisterValidationInterface(CValidationInterface*);
friend void UnregisterAllValidationInterfaces();
};

struct MainSignalsInstance;
Expand Down

0 comments on commit 47711fd

Please sign in to comment.