]>
Commit | Line | Data |
---|---|---|
26c16d9d JT |
1 | // Copyright (c) 2009-2010 Satoshi Nakamoto |
2 | // Copyright (c) 2009-2014 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. | |
5 | ||
6 | #ifndef BITCOIN_VALIDATIONINTERFACE_H | |
7 | #define BITCOIN_VALIDATIONINTERFACE_H | |
8 | ||
9 | #include <boost/signals2/signal.hpp> | |
10 | ||
de42390f JG |
11 | #include "zcash/IncrementalMerkleTree.hpp" |
12 | ||
26c16d9d | 13 | class CBlock; |
769e031c | 14 | class CBlockIndex; |
63e4c9cd | 15 | struct CBlockLocator; |
26c16d9d JT |
16 | class CTransaction; |
17 | class CValidationInterface; | |
18 | class CValidationState; | |
19 | class uint256; | |
20 | ||
21 | // These functions dispatch to one or all registered wallets | |
22 | ||
23 | /** Register a wallet to receive updates from core */ | |
24 | void RegisterValidationInterface(CValidationInterface* pwalletIn); | |
25 | /** Unregister a wallet from core */ | |
26 | void UnregisterValidationInterface(CValidationInterface* pwalletIn); | |
27 | /** Unregister all wallets from core */ | |
28 | void UnregisterAllValidationInterfaces(); | |
29 | /** Push an updated transaction to all registered wallets */ | |
30 | void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL); | |
31 | ||
32 | class CValidationInterface { | |
33 | protected: | |
0a7bcb7e PK |
34 | virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {} |
35 | virtual void EraseFromWallet(const uint256 &hash) {} | |
de42390f | 36 | virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, ZCIncrementalMerkleTree tree, bool added) {} |
0a7bcb7e PK |
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) {} | |
41 | virtual void BlockChecked(const CBlock&, const CValidationState&) {} | |
26c16d9d JT |
42 | friend void ::RegisterValidationInterface(CValidationInterface*); |
43 | friend void ::UnregisterValidationInterface(CValidationInterface*); | |
44 | friend void ::UnregisterAllValidationInterfaces(); | |
45 | }; | |
46 | ||
47 | struct CMainSignals { | |
48 | /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */ | |
49 | boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction; | |
50 | /** Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). */ | |
51 | boost::signals2::signal<void (const uint256 &)> EraseTransaction; | |
52 | /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */ | |
53 | boost::signals2::signal<void (const uint256 &)> UpdatedTransaction; | |
769e031c | 54 | /** Notifies listeners of a change to the tip of the active block chain. */ |
de42390f | 55 | boost::signals2::signal<void (const CBlockIndex *, const CBlock *, ZCIncrementalMerkleTree, bool)> ChainTip; |
26c16d9d JT |
56 | /** Notifies listeners of a new active block chain. */ |
57 | boost::signals2::signal<void (const CBlockLocator &)> SetBestChain; | |
58 | /** Notifies listeners about an inventory item being seen on the network. */ | |
59 | boost::signals2::signal<void (const uint256 &)> Inventory; | |
60 | /** Tells listeners to broadcast their data. */ | |
0f5954c4 | 61 | boost::signals2::signal<void (int64_t nBestBlockTime)> Broadcast; |
26c16d9d JT |
62 | /** Notifies listeners of a block validation result */ |
63 | boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked; | |
64 | }; | |
65 | ||
66 | CMainSignals& GetMainSignals(); | |
67 | ||
68 | #endif // BITCOIN_VALIDATIONINTERFACE_H |