Changeset View
Changeset View
Standalone View
Standalone View
src/validationinterface.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_VALIDATIONINTERFACE_H | #ifndef BITCOIN_VALIDATIONINTERFACE_H | ||||
#define BITCOIN_VALIDATIONINTERFACE_H | #define BITCOIN_VALIDATIONINTERFACE_H | ||||
#include "primitives/transaction.h" // CTransaction(Ref) | #include "primitives/transaction.h" // CTransaction(Ref) | ||||
#include <functional> | |||||
#include <memory> | #include <memory> | ||||
class CBlock; | class CBlock; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
struct CBlockLocator; | struct CBlockLocator; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
class CConnman; | class CConnman; | ||||
class CReserveScript; | class CReserveScript; | ||||
class CValidationInterface; | class CValidationInterface; | ||||
class CValidationState; | class CValidationState; | ||||
class uint256; | class uint256; | ||||
class CScheduler; | class CScheduler; | ||||
class CTxMemPool; | class CTxMemPool; | ||||
enum class MemPoolRemovalReason; | enum class MemPoolRemovalReason; | ||||
// 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(); | ||||
/** | |||||
* Pushes a function to callback onto the notification queue, guaranteeing any | |||||
* 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 - | |||||
* 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 | |||||
* will result in a deadlock (that DEBUG_LOCKORDER will miss). | |||||
*/ | |||||
void CallFunctionInValidationInterfaceQueue(std::function<void()> func); | |||||
class CValidationInterface { | class CValidationInterface { | ||||
protected: | protected: | ||||
/** | /** | ||||
* Protected destructor so that instances can only be deleted by derived | * Protected destructor so that instances can only be deleted by derived | ||||
* classes. If that restriction is no longer desired, this should be made | * classes. If that restriction is no longer desired, this should be made | ||||
* public and virtual. | * public and virtual. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
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 ::RegisterValidationInterface(CValidationInterface *); | ||||
friend void ::UnregisterValidationInterface(CValidationInterface *); | friend void ::UnregisterValidationInterface(CValidationInterface *); | ||||
friend void ::UnregisterAllValidationInterfaces(); | friend void ::UnregisterAllValidationInterfaces(); | ||||
friend void ::CallFunctionInValidationInterfaceQueue( | |||||
std::function<void()> func); | |||||
void MempoolEntryRemoved(CTransactionRef tx, MemPoolRemovalReason reason); | void MempoolEntryRemoved(CTransactionRef tx, MemPoolRemovalReason reason); | ||||
public: | public: | ||||
/** | /** | ||||
* Register a CScheduler to give callbacks which should run in the | * Register a CScheduler to give callbacks which should run in the | ||||
* background (may only be called once) | * background (may only be called once) | ||||
*/ | */ | ||||
Show All 32 Lines |