Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

validationinterface.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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 <primitives/transaction.h> // CTransaction(Ref)
10 
11 #include <functional>
12 #include <memory>
13 
14 class CBlock;
15 class CBlockIndex;
16 struct CBlockLocator;
17 class CConnman;
18 class CReserveScript;
20 class CValidationState;
21 class CGovernanceVote;
22 class CGovernanceObject;
25 class uint256;
26 class CScheduler;
27 class CTxMemPool;
28 enum class MemPoolRemovalReason;
29 
30 namespace llmq {
31  class CChainLockSig;
32  class CInstantSendLock;
33 } // namespace llmq
34 
35 // These functions dispatch to one or all registered wallets
36 
52 void CallFunctionInValidationInterfaceQueue(std::function<void ()> func);
63 
65 protected:
66  virtual void AcceptedBlockHeader(const CBlockIndex *pindexNew) {}
67  virtual void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload) {}
73  virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
77  virtual void SynchronousUpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
83  virtual void TransactionAddedToMempool(const CTransactionRef &ptxn, int64_t nAcceptTime) {}
94  virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) {}
101  virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex, const std::vector<CTransactionRef> &txnConflicted) {}
107  virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindexDisconnected) {}
108  virtual void NotifyTransactionLock(const CTransaction &tx, const llmq::CInstantSendLock& islock) {}
109  virtual void NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig) {}
110  virtual void NotifyGovernanceVote(const CGovernanceVote &vote) {}
111  virtual void NotifyGovernanceObject(const CGovernanceObject &object) {}
112  virtual void NotifyInstantSendDoubleSpendAttempt(const CTransaction &currentTx, const CTransaction &previousTx) {}
113  virtual void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) {}
119  virtual void SetBestChain(const CBlockLocator &locator) {}
121  virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
128  virtual void BlockChecked(const CBlock&, const CValidationState&) {}
132  virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
136 };
137 
138 struct MainSignalsInstance;
140 private:
141  std::unique_ptr<MainSignalsInstance> m_internals;
142 
146  friend void ::CallFunctionInValidationInterfaceQueue(std::function<void ()> func);
147 
149 
150 public:
157 
158  size_t CallbacksPending();
159 
164 
165  void AcceptedBlockHeader(const CBlockIndex *pindexNew);
166  void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload);
167  void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
168  void SynchronousUpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
169  void TransactionAddedToMempool(const CTransactionRef &, int64_t);
170  void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>> &);
171  void BlockDisconnected(const std::shared_ptr<const CBlock> &, const CBlockIndex* pindexDisconnected);
172  void NotifyTransactionLock(const CTransaction &tx, const llmq::CInstantSendLock& islock);
173  void NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig);
174  void NotifyGovernanceVote(const CGovernanceVote &vote);
175  void NotifyGovernanceObject(const CGovernanceObject &object);
176  void NotifyInstantSendDoubleSpendAttempt(const CTransaction &currentTx, const CTransaction &previousTx);
177  void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff);
178  void SetBestChain(const CBlockLocator &);
179  void Broadcast(int64_t nBestBlockTime, CConnman* connman);
180  void BlockChecked(const CBlock&, const CValidationState&);
181  void NewPoWValidBlock(const CBlockIndex *, const std::shared_ptr<const CBlock>&);
182 };
183 
185 
186 #endif // BITCOIN_VALIDATIONINTERFACE_H
void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)
std::unique_ptr< MainSignalsInstance > m_internals
virtual void BlockChecked(const CBlock &, const CValidationState &)
Notifies listeners of a block validation result.
virtual void TransactionAddedToMempool(const CTransactionRef &ptxn, int64_t nAcceptTime)
Notifies listeners of a transaction having been added to mempool.
virtual void AcceptedBlockHeader(const CBlockIndex *pindexNew)
Governance Object.
virtual void NotifyGovernanceVote(const CGovernanceVote &vote)
Describes a place in the block chain to another node such that if the other node doesn&#39;t have the sam...
Definition: block.h:127
void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload)
void SynchronousUpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)
void BlockDisconnected(const std::shared_ptr< const CBlock > &, const CBlockIndex *pindexDisconnected)
Definition: block.h:72
void NotifyGovernanceVote(const CGovernanceVote &vote)
void TransactionAddedToMempool(const CTransactionRef &, int64_t)
virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman *connman)
Tells listeners to broadcast their data.
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &block)
Notifies listeners that a block which builds directly on our current tip has been received and connec...
void UnregisterBackgroundSignalScheduler()
Unregister a CScheduler to give callbacks which should run in the background - these callbacks will n...
void NotifyChainLock(const CBlockIndex *pindex, const llmq::CChainLockSig &clsig)
virtual void SetBestChain(const CBlockLocator &locator)
Notifies listeners of the new active block chain on-disk.
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
Definition: txmempool.h:349
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
void Broadcast(int64_t nBestBlockTime, CConnman *connman)
static CScheduler scheduler
Definition: init.cpp:213
void BlockChecked(const CBlock &, const CValidationState &)
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:345
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList &oldMNList, const CDeterministicMNListDiff &diff)
void NotifyGovernanceObject(const CGovernanceObject &object)
virtual void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload)
virtual void NotifyChainLock(const CBlockIndex *pindex, const llmq::CChainLockSig &clsig)
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
virtual void NotifyInstantSendDoubleSpendAttempt(const CTransaction &currentTx, const CTransaction &previousTx)
virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
Notifies listeners of updated block chain tip.
void RegisterWithMempoolSignals(CTxMemPool &pool)
Register with mempool to call TransactionRemovedFromMempool callbacks.
virtual void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList &oldMNList, const CDeterministicMNListDiff &diff)
void CallFunctionInValidationInterfaceQueue(std::function< void()> func)
Pushes a function to callback onto the notification queue, guaranteeing any callbacks generated prior...
void UnregisterWithMempoolSignals(CTxMemPool &pool)
Unregister with mempool.
Definition: net.h:136
void AcceptedBlockHeader(const CBlockIndex *pindexNew)
virtual void BlockDisconnected(const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindexDisconnected)
Notifies listeners of a block being disconnected.
virtual void NotifyGovernanceObject(const CGovernanceObject &object)
CMainSignals & GetMainSignals()
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once) ...
Capture information about block/transaction validation.
Definition: validation.h:22
256-bit opaque blob.
Definition: uint256.h:123
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:442
virtual void NotifyTransactionLock(const CTransaction &tx, const llmq::CInstantSendLock &islock)
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
void FlushBackgroundCallbacks()
Call any remaining callbacks on the calling thread.
void MempoolEntryRemoved(CTransactionRef tx, MemPoolRemovalReason reason)
void NotifyInstantSendDoubleSpendAttempt(const CTransaction &currentTx, const CTransaction &previousTx)
void UnregisterAllValidationInterfaces()
Unregister all wallets from core.
virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx)
Notifies listeners of a transaction leaving mempool.
virtual void SynchronousUpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
Same as UpdatedBlockTip, but called from the caller&#39;s thread.
virtual void BlockConnected(const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex, const std::vector< CTransactionRef > &txnConflicted)
Notifies listeners of a block being connected.
void SetBestChain(const CBlockLocator &)
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
void NewPoWValidBlock(const CBlockIndex *, const std::shared_ptr< const CBlock > &)
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
void NotifyTransactionLock(const CTransaction &tx, const llmq::CInstantSendLock &islock)
void BlockConnected(const std::shared_ptr< const CBlock > &, const CBlockIndex *pindex, const std::shared_ptr< const std::vector< CTransactionRef >> &)
Released under the MIT license