mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Add a CValidationInterface::NewPoWValidBlock callback
This commit is contained in:
parent
180586fd44
commit
6987219577
@ -3096,6 +3096,11 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
|
||||
return error("%s: %s", __func__, FormatStateMessage(state));
|
||||
}
|
||||
|
||||
// Header is valid/has work, merkle tree and segwit merkle tree are good...RELAY NOW
|
||||
// (but if it does not build on our best tip, let the SendMessages loop relay it)
|
||||
if (!IsInitialBlockDownload() && chainActive.Tip() == pindex->pprev)
|
||||
GetMainSignals().NewPoWValidBlock(pindex, pblock);
|
||||
|
||||
int nHeight = pindex->nHeight;
|
||||
|
||||
// Write block to history file
|
||||
|
@ -22,6 +22,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||
g_signals.BlockChecked.connect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2));
|
||||
g_signals.ScriptForMining.connect(boost::bind(&CValidationInterface::GetScriptForMining, pwalletIn, _1));
|
||||
g_signals.BlockFound.connect(boost::bind(&CValidationInterface::ResetRequestCount, pwalletIn, _1));
|
||||
g_signals.NewPoWValidBlock.connect(boost::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2));
|
||||
}
|
||||
|
||||
void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||
@ -34,6 +35,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||
g_signals.UpdatedTransaction.disconnect(boost::bind(&CValidationInterface::UpdatedTransaction, pwalletIn, _1));
|
||||
g_signals.SyncTransaction.disconnect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));
|
||||
g_signals.UpdatedBlockTip.disconnect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
|
||||
g_signals.NewPoWValidBlock.disconnect(boost::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2));
|
||||
}
|
||||
|
||||
void UnregisterAllValidationInterfaces() {
|
||||
@ -46,4 +48,5 @@ void UnregisterAllValidationInterfaces() {
|
||||
g_signals.UpdatedTransaction.disconnect_all_slots();
|
||||
g_signals.SyncTransaction.disconnect_all_slots();
|
||||
g_signals.UpdatedBlockTip.disconnect_all_slots();
|
||||
g_signals.NewPoWValidBlock.disconnect_all_slots();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <memory>
|
||||
|
||||
class CBlock;
|
||||
class CBlockIndex;
|
||||
@ -40,6 +41,7 @@ protected:
|
||||
virtual void BlockChecked(const CBlock&, const CValidationState&) {}
|
||||
virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {};
|
||||
virtual void ResetRequestCount(const uint256 &hash) {};
|
||||
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
|
||||
friend void ::RegisterValidationInterface(CValidationInterface*);
|
||||
friend void ::UnregisterValidationInterface(CValidationInterface*);
|
||||
friend void ::UnregisterAllValidationInterfaces();
|
||||
@ -66,6 +68,10 @@ struct CMainSignals {
|
||||
boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining;
|
||||
/** Notifies listeners that a block has been successfully mined */
|
||||
boost::signals2::signal<void (const uint256 &)> BlockFound;
|
||||
/**
|
||||
* Notifies listeners that a block which builds directly on our current tip
|
||||
* has been received and connected to the headers tree, though not validated yet */
|
||||
boost::signals2::signal<void (const CBlockIndex *, const std::shared_ptr<const CBlock>&)> NewPoWValidBlock;
|
||||
};
|
||||
|
||||
CMainSignals& GetMainSignals();
|
||||
|
Loading…
Reference in New Issue
Block a user