SyncTransaction->TxAddedToMempool/BlockConnected/Disconnected
[bitcoinplatinum.git] / src / validationinterface.h
blobddb0afbb4d300520f5c7434856e9e77b68eeaf0c
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_VALIDATIONINTERFACE_H
7 #define BITCOIN_VALIDATIONINTERFACE_H
9 #include <boost/signals2/signal.hpp>
10 #include <boost/shared_ptr.hpp>
11 #include <memory>
13 #include "primitives/transaction.h" // CTransaction(Ref)
15 class CBlock;
16 class CBlockIndex;
17 struct CBlockLocator;
18 class CBlockIndex;
19 class CConnman;
20 class CReserveScript;
21 class CValidationInterface;
22 class CValidationState;
23 class uint256;
25 // These functions dispatch to one or all registered wallets
27 /** Register a wallet to receive updates from core */
28 void RegisterValidationInterface(CValidationInterface* pwalletIn);
29 /** Unregister a wallet from core */
30 void UnregisterValidationInterface(CValidationInterface* pwalletIn);
31 /** Unregister all wallets from core */
32 void UnregisterAllValidationInterfaces();
34 class CValidationInterface {
35 protected:
36 virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
37 virtual void TransactionAddedToMempool(const CTransactionRef &ptxn) {}
38 virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex, const std::vector<CTransactionRef> &txnConflicted) {}
39 virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block) {}
40 virtual void SetBestChain(const CBlockLocator &locator) {}
41 virtual void UpdatedTransaction(const uint256 &hash) {}
42 virtual void Inventory(const uint256 &hash) {}
43 virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
44 virtual void BlockChecked(const CBlock&, const CValidationState&) {}
45 virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {};
46 virtual void ResetRequestCount(const uint256 &hash) {};
47 virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
48 friend void ::RegisterValidationInterface(CValidationInterface*);
49 friend void ::UnregisterValidationInterface(CValidationInterface*);
50 friend void ::UnregisterAllValidationInterfaces();
53 struct CMainSignals {
54 /** Notifies listeners of updated block chain tip */
55 boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
56 /** Notifies listeners of a transaction having been added to mempool. */
57 boost::signals2::signal<void (const CTransactionRef &)> TransactionAddedToMempool;
58 /**
59 * Notifies listeners of a block being connected.
60 * Provides a vector of transactions evicted from the mempool as a result.
62 boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef> &)> BlockConnected;
63 /** Notifies listeners of a block being disconnected */
64 boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
65 /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
66 boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
67 /** Notifies listeners of a new active block chain. */
68 boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
69 /** Notifies listeners about an inventory item being seen on the network. */
70 boost::signals2::signal<void (const uint256 &)> Inventory;
71 /** Tells listeners to broadcast their data. */
72 boost::signals2::signal<void (int64_t nBestBlockTime, CConnman* connman)> Broadcast;
73 /**
74 * Notifies listeners of a block validation result.
75 * If the provided CValidationState IsValid, the provided block
76 * is guaranteed to be the current best block at the time the
77 * callback was generated (not necessarily now)
79 boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
80 /** Notifies listeners that a key for mining is required (coinbase) */
81 boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining;
82 /** Notifies listeners that a block has been successfully mined */
83 boost::signals2::signal<void (const uint256 &)> BlockFound;
84 /**
85 * Notifies listeners that a block which builds directly on our current tip
86 * has been received and connected to the headers tree, though not validated yet */
87 boost::signals2::signal<void (const CBlockIndex *, const std::shared_ptr<const CBlock>&)> NewPoWValidBlock;
90 CMainSignals& GetMainSignals();
92 #endif // BITCOIN_VALIDATIONINTERFACE_H