Changeset View
Changeset View
Standalone View
Standalone View
src/validationinterface.h
Show All 26 Lines | |||||
// These functions dispatch to one or all registered wallets | // These functions dispatch to one or all registered wallets | ||||
/** Register a wallet to receive updates from core */ | /** Register a wallet to receive updates from core */ | ||||
void RegisterValidationInterface(CValidationInterface *pwalletIn); | void RegisterValidationInterface(CValidationInterface *pwalletIn); | ||||
/** Unregister a wallet from core */ | /** Unregister a wallet from core */ | ||||
void UnregisterValidationInterface(CValidationInterface *pwalletIn); | void UnregisterValidationInterface(CValidationInterface *pwalletIn); | ||||
/** Unregister all wallets from core */ | /** Unregister all wallets from core */ | ||||
void UnregisterAllValidationInterfaces(); | void UnregisterAllValidationInterfaces(); | ||||
// Alternate registration functions that release a shared_ptr after the last | |||||
// notification is sent. These are useful for race-free cleanup, since | |||||
// unregistration is nonblocking and can return before the last notification is | |||||
// processed. | |||||
void RegisterSharedValidationInterface( | |||||
std::shared_ptr<CValidationInterface> callbacks); | |||||
void UnregisterSharedValidationInterface( | |||||
std::shared_ptr<CValidationInterface> callbacks); | |||||
/** | /** | ||||
* Pushes a function to callback onto the notification queue, guaranteeing any | * Pushes a function to callback onto the notification queue, guaranteeing any | ||||
* callbacks generated prior to now are finished when the function is called. | * callbacks generated prior to now are finished when the function is called. | ||||
* | * | ||||
* Be very careful blocking on func to be called if any locks are held - | * Be very careful blocking on func to be called if any locks are held - | ||||
* validation interface clients may not be able to make progress as they often | * validation interface clients may not be able to make progress as they often | ||||
* wait for things like cs_main, so blocking until func is called with cs_main | * wait for things like cs_main, so blocking until func is called with cs_main | ||||
* will result in a deadlock (that DEBUG_LOCKORDER will miss). | * will result in a deadlock (that DEBUG_LOCKORDER will miss). | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | protected: | ||||
virtual void BlockChecked(const CBlock &, const CValidationState &) {} | virtual void BlockChecked(const CBlock &, const CValidationState &) {} | ||||
/** | /** | ||||
* Notifies listeners that a block which builds directly on our current tip | * Notifies listeners that a block which builds directly on our current tip | ||||
* has been received and connected to the headers tree, though not validated | * has been received and connected to the headers tree, though not validated | ||||
* yet. | * yet. | ||||
*/ | */ | ||||
virtual void NewPoWValidBlock(const CBlockIndex *pindex, | virtual void NewPoWValidBlock(const CBlockIndex *pindex, | ||||
const std::shared_ptr<const CBlock> &block){}; | const std::shared_ptr<const CBlock> &block){}; | ||||
friend void ::RegisterValidationInterface(CValidationInterface *); | friend void ::RegisterSharedValidationInterface( | ||||
std::shared_ptr<CValidationInterface>); | |||||
friend void ::UnregisterValidationInterface(CValidationInterface *); | friend void ::UnregisterValidationInterface(CValidationInterface *); | ||||
friend void ::UnregisterAllValidationInterfaces(); | friend void ::UnregisterAllValidationInterfaces(); | ||||
}; | }; | ||||
struct MainSignalsInstance; | struct MainSignalsInstance; | ||||
class CMainSignals { | class CMainSignals { | ||||
private: | private: | ||||
std::unique_ptr<MainSignalsInstance> m_internals; | std::unique_ptr<MainSignalsInstance> m_internals; | ||||
friend void ::RegisterValidationInterface(CValidationInterface *); | friend void ::RegisterSharedValidationInterface( | ||||
std::shared_ptr<CValidationInterface>); | |||||
friend void ::UnregisterValidationInterface(CValidationInterface *); | friend void ::UnregisterValidationInterface(CValidationInterface *); | ||||
friend void ::UnregisterAllValidationInterfaces(); | friend void ::UnregisterAllValidationInterfaces(); | ||||
friend void ::CallFunctionInValidationInterfaceQueue( | friend void ::CallFunctionInValidationInterfaceQueue( | ||||
std::function<void()> func); | std::function<void()> func); | ||||
public: | public: | ||||
/** | /** | ||||
* Register a CScheduler to give callbacks which should run in the | * Register a CScheduler to give callbacks which should run in the | ||||
Show All 31 Lines |