Add Pieter's old signed commits to revsig-commits
[bitcoinplatinum.git] / src / validationinterface.h
bloba494eb6990fee9db508b77cc26b26a7504613982
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 class CBlock;
14 class CBlockIndex;
15 struct CBlockLocator;
16 class CBlockIndex;
17 class CConnman;
18 class CReserveScript;
19 class CTransaction;
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 SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) {}
37 virtual void SetBestChain(const CBlockLocator &locator) {}
38 virtual void UpdatedTransaction(const uint256 &hash) {}
39 virtual void Inventory(const uint256 &hash) {}
40 virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
41 virtual void BlockChecked(const CBlock&, const CValidationState&) {}
42 virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {};
43 virtual void ResetRequestCount(const uint256 &hash) {};
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 /** A posInBlock value for SyncTransaction calls for transactions not
54 * included in connected blocks such as transactions removed from mempool,
55 * accepted to mempool or appearing in disconnected blocks.*/
56 static const int SYNC_TRANSACTION_NOT_IN_BLOCK = -1;
57 /** Notifies listeners of updated transaction data (transaction, and
58 * optionally the block it is found in). Called with block data when
59 * transaction is included in a connected block, and without block data when
60 * transaction was accepted to mempool, removed from mempool (only when
61 * removal was due to conflict from connected block), or appeared in a
62 * disconnected block.*/
63 boost::signals2::signal<void (const CTransaction &, const CBlockIndex *pindex, int posInBlock)> SyncTransaction;
64 /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
65 boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
66 /** Notifies listeners of a new active block chain. */
67 boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
68 /** Notifies listeners about an inventory item being seen on the network. */
69 boost::signals2::signal<void (const uint256 &)> Inventory;
70 /** Tells listeners to broadcast their data. */
71 boost::signals2::signal<void (int64_t nBestBlockTime, CConnman* connman)> Broadcast;
72 /** Notifies listeners of a block validation result */
73 boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
74 /** Notifies listeners that a key for mining is required (coinbase) */
75 boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining;
76 /** Notifies listeners that a block has been successfully mined */
77 boost::signals2::signal<void (const uint256 &)> BlockFound;
78 /**
79 * Notifies listeners that a block which builds directly on our current tip
80 * has been received and connected to the headers tree, though not validated yet */
81 boost::signals2::signal<void (const CBlockIndex *, const std::shared_ptr<const CBlock>&)> NewPoWValidBlock;
84 CMainSignals& GetMainSignals();
86 #endif // BITCOIN_VALIDATIONINTERFACE_H