Merge #10432: [Trivial] Add BITCOIN_FS_H endif footer in fs.h
[bitcoinplatinum.git] / src / validationinterface.h
blob460aecf243fa25fa7e3f6f6b7d191d6286ff4b2c
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 <memory>
12 #include "primitives/transaction.h" // CTransaction(Ref)
14 class CBlock;
15 class CBlockIndex;
16 struct CBlockLocator;
17 class CBlockIndex;
18 class CConnman;
19 class CReserveScript;
20 class CValidationInterface;
21 class CValidationState;
22 class uint256;
24 // These functions dispatch to one or all registered wallets
26 /** Register a wallet to receive updates from core */
27 void RegisterValidationInterface(CValidationInterface* pwalletIn);
28 /** Unregister a wallet from core */
29 void UnregisterValidationInterface(CValidationInterface* pwalletIn);
30 /** Unregister all wallets from core */
31 void UnregisterAllValidationInterfaces();
33 class CValidationInterface {
34 protected:
35 virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
36 virtual void TransactionAddedToMempool(const CTransactionRef &ptxn) {}
37 virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex, const std::vector<CTransactionRef> &txnConflicted) {}
38 virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block) {}
39 virtual void SetBestChain(const CBlockLocator &locator) {}
40 virtual void Inventory(const uint256 &hash) {}
41 virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
42 virtual void BlockChecked(const CBlock&, const CValidationState&) {}
43 virtual void GetScriptForMining(std::shared_ptr<CReserveScript>&) {};
44 virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
45 friend void ::RegisterValidationInterface(CValidationInterface*);
46 friend void ::UnregisterValidationInterface(CValidationInterface*);
47 friend void ::UnregisterAllValidationInterfaces();
50 struct CMainSignals {
51 /** Notifies listeners of updated block chain tip */
52 boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
53 /** Notifies listeners of a transaction having been added to mempool. */
54 boost::signals2::signal<void (const CTransactionRef &)> TransactionAddedToMempool;
55 /**
56 * Notifies listeners of a block being connected.
57 * Provides a vector of transactions evicted from the mempool as a result.
59 boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef> &)> BlockConnected;
60 /** Notifies listeners of a block being disconnected */
61 boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
62 /** Notifies listeners of a new active block chain. */
63 boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
64 /** Notifies listeners about an inventory item being seen on the network. */
65 boost::signals2::signal<void (const uint256 &)> Inventory;
66 /** Tells listeners to broadcast their data. */
67 boost::signals2::signal<void (int64_t nBestBlockTime, CConnman* connman)> Broadcast;
68 /**
69 * Notifies listeners of a block validation result.
70 * If the provided CValidationState IsValid, the provided block
71 * is guaranteed to be the current best block at the time the
72 * callback was generated (not necessarily now)
74 boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
75 /** Notifies listeners that a key for mining is required (coinbase) */
76 boost::signals2::signal<void (std::shared_ptr<CReserveScript>&)> ScriptForMining;
77 /**
78 * Notifies listeners that a block which builds directly on our current tip
79 * has been received and connected to the headers tree, though not validated yet */
80 boost::signals2::signal<void (const CBlockIndex *, const std::shared_ptr<const CBlock>&)> NewPoWValidBlock;
83 CMainSignals& GetMainSignals();
85 #endif // BITCOIN_VALIDATIONINTERFACE_H