mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: drop circular dependency validationinterface <-> governance/object
This commit is contained in:
parent
4de30f4b61
commit
7e13727738
@ -8,6 +8,7 @@
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <governance/common.h>
|
||||
#include <llmq/chainlocks.h>
|
||||
#include <llmq/instantsend.h>
|
||||
#include <llmq/utils.h>
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <flat-database.h>
|
||||
#include <governance/classes.h>
|
||||
#include <governance/common.h>
|
||||
#include <governance/validators.h>
|
||||
#include <masternode/meta.h>
|
||||
#include <masternode/node.h>
|
||||
@ -333,7 +334,7 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
|
||||
CheckOrphanVotes(govobj, connman);
|
||||
|
||||
// SEND NOTIFICATION TO SCRIPT/ZMQ
|
||||
GetMainSignals().NotifyGovernanceObject(std::make_shared<const CGovernanceObject>(govobj));
|
||||
GetMainSignals().NotifyGovernanceObject(std::make_shared<const Governance::Object>(govobj.Object()));
|
||||
}
|
||||
|
||||
void CGovernanceManager::UpdateCachesAndClean()
|
||||
|
@ -145,6 +145,11 @@ public:
|
||||
|
||||
// Public Getter methods
|
||||
|
||||
const Governance::Object& Object() const
|
||||
{
|
||||
return m_obj;
|
||||
}
|
||||
|
||||
int64_t GetCreationTime() const
|
||||
{
|
||||
return m_obj.time;
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include <chain.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <governance/common.h>
|
||||
#include <logging.h>
|
||||
#include <primitives/block.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <scheduler.h>
|
||||
|
||||
#include <governance/object.h>
|
||||
#include <governance/vote.h>
|
||||
#include <llmq/clsig.h>
|
||||
#include <llmq/signing.h>
|
||||
@ -295,7 +295,7 @@ void CMainSignals::NotifyGovernanceVote(const std::shared_ptr<const CGovernanceV
|
||||
ENQUEUE_AND_LOG_EVENT(event, "%s: notify governance vote: %s", __func__, vote->GetHash().ToString());
|
||||
}
|
||||
|
||||
void CMainSignals::NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object) {
|
||||
void CMainSignals::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) {
|
||||
auto event = [object, this] {
|
||||
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.NotifyGovernanceObject(object); });
|
||||
};
|
||||
|
@ -20,13 +20,17 @@ struct CBlockLocator;
|
||||
class CConnman;
|
||||
class CValidationInterface;
|
||||
class CGovernanceVote;
|
||||
class CGovernanceObject;
|
||||
class CDeterministicMNList;
|
||||
class CDeterministicMNListDiff;
|
||||
class uint256;
|
||||
class CScheduler;
|
||||
enum class MemPoolRemovalReason;
|
||||
|
||||
namespace Governance
|
||||
{
|
||||
class Object;
|
||||
}
|
||||
|
||||
namespace llmq {
|
||||
class CChainLockSig;
|
||||
struct CInstantSendLock;
|
||||
@ -162,7 +166,7 @@ protected:
|
||||
virtual void NotifyTransactionLock(const CTransactionRef &tx, const std::shared_ptr<const llmq::CInstantSendLock>& islock) {}
|
||||
virtual void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) {}
|
||||
virtual void NotifyGovernanceVote(const std::shared_ptr<const CGovernanceVote>& vote) {}
|
||||
virtual void NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object) {}
|
||||
virtual void NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) {}
|
||||
virtual void NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& currentTx, const CTransactionRef& previousTx) {}
|
||||
virtual void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig) {}
|
||||
virtual void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff) {}
|
||||
@ -229,7 +233,7 @@ public:
|
||||
void NotifyTransactionLock(const CTransactionRef &tx, const std::shared_ptr<const llmq::CInstantSendLock>& islock);
|
||||
void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig);
|
||||
void NotifyGovernanceVote(const std::shared_ptr<const CGovernanceVote>& vote);
|
||||
void NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object);
|
||||
void NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object);
|
||||
void NotifyInstantSendDoubleSpendAttempt(const CTransactionRef ¤tTx, const CTransactionRef &previousTx);
|
||||
void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig> &sig);
|
||||
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff);
|
||||
|
@ -38,7 +38,7 @@ bool CZMQAbstractNotifier::NotifyGovernanceVote(const std::shared_ptr<const CGov
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CZMQAbstractNotifier::NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject> & /*object*/)
|
||||
bool CZMQAbstractNotifier::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object> & /*object*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -10,13 +10,17 @@
|
||||
#include <string>
|
||||
|
||||
class CBlockIndex;
|
||||
class CGovernanceObject;
|
||||
class CGovernanceVote;
|
||||
class CTransaction;
|
||||
class CZMQAbstractNotifier;
|
||||
|
||||
typedef std::shared_ptr<const CTransaction> CTransactionRef;
|
||||
|
||||
namespace Governance
|
||||
{
|
||||
class Object;
|
||||
} //namespace Governance
|
||||
|
||||
namespace llmq {
|
||||
class CChainLockSig;
|
||||
struct CInstantSendLock;
|
||||
@ -58,7 +62,7 @@ public:
|
||||
virtual bool NotifyTransaction(const CTransaction &transaction);
|
||||
virtual bool NotifyTransactionLock(const CTransactionRef& transaction, const std::shared_ptr<const llmq::CInstantSendLock>& islock);
|
||||
virtual bool NotifyGovernanceVote(const std::shared_ptr<const CGovernanceVote>& vote);
|
||||
virtual bool NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object);
|
||||
virtual bool NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object);
|
||||
virtual bool NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& currentTx, const CTransactionRef& previousTx);
|
||||
virtual bool NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig);
|
||||
|
||||
|
@ -198,7 +198,7 @@ void CZMQNotificationInterface::NotifyGovernanceVote(const std::shared_ptr<const
|
||||
});
|
||||
}
|
||||
|
||||
void CZMQNotificationInterface::NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject> &object)
|
||||
void CZMQNotificationInterface::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object> &object)
|
||||
{
|
||||
TryForEachAndRemoveFailed(notifiers, [&object](CZMQAbstractNotifier* notifier) {
|
||||
return notifier->NotifyGovernanceObject(object);
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
void NotifyChainLock(const CBlockIndex *pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) override;
|
||||
void NotifyTransactionLock(const CTransactionRef &tx, const std::shared_ptr<const llmq::CInstantSendLock>& islock) override;
|
||||
void NotifyGovernanceVote(const std::shared_ptr<const CGovernanceVote>& vote) override;
|
||||
void NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object) override;
|
||||
void NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) override;
|
||||
void NotifyInstantSendDoubleSpendAttempt(const CTransactionRef& currentTx, const CTransactionRef& previousTx) override;
|
||||
void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig) override;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <validation.h>
|
||||
#include <zmq/zmqutil.h>
|
||||
|
||||
#include <governance/object.h>
|
||||
#include <governance/common.h>
|
||||
#include <governance/vote.h>
|
||||
|
||||
#include <llmq/chainlocks.h>
|
||||
@ -245,7 +245,7 @@ bool CZMQPublishHashGovernanceVoteNotifier::NotifyGovernanceVote(const std::shar
|
||||
return SendZmqMessage(MSG_HASHGVOTE, data, 32);
|
||||
}
|
||||
|
||||
bool CZMQPublishHashGovernanceObjectNotifier::NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object)
|
||||
bool CZMQPublishHashGovernanceObjectNotifier::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object)
|
||||
{
|
||||
uint256 hash = object->GetHash();
|
||||
LogPrint(BCLog::ZMQ, "zmq: Publish hashgovernanceobject %s\n", hash.GetHex());
|
||||
@ -378,10 +378,10 @@ bool CZMQPublishRawGovernanceVoteNotifier::NotifyGovernanceVote(const std::share
|
||||
return SendZmqMessage(MSG_RAWGVOTE, &(*ss.begin()), ss.size());
|
||||
}
|
||||
|
||||
bool CZMQPublishRawGovernanceObjectNotifier::NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& govobj)
|
||||
bool CZMQPublishRawGovernanceObjectNotifier::NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& govobj)
|
||||
{
|
||||
uint256 nHash = govobj->GetHash();
|
||||
LogPrint(BCLog::ZMQ, "zmq: Publish rawgovernanceobject: hash = %s to %s, type = %d\n", nHash.ToString(), this->address, ToUnderlying(govobj->GetObjectType()));
|
||||
LogPrint(BCLog::ZMQ, "zmq: Publish rawgovernanceobject: hash = %s to %s, type = %d\n", nHash.ToString(), this->address, ToUnderlying(govobj->type));
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << *govobj;
|
||||
return SendZmqMessage(MSG_RAWGOBJ, &(*ss.begin()), ss.size());
|
||||
|
@ -9,7 +9,12 @@
|
||||
|
||||
class CBlockIndex;
|
||||
class CGovernanceVote;
|
||||
class CGovernanceObject;
|
||||
|
||||
namespace Governance
|
||||
{
|
||||
class Object;
|
||||
} //namespace Governance
|
||||
|
||||
|
||||
class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier
|
||||
{
|
||||
@ -63,7 +68,7 @@ public:
|
||||
class CZMQPublishHashGovernanceObjectNotifier : public CZMQAbstractPublishNotifier
|
||||
{
|
||||
public:
|
||||
bool NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object) override;
|
||||
bool NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) override;
|
||||
};
|
||||
|
||||
class CZMQPublishHashInstantSendDoubleSpendNotifier : public CZMQAbstractPublishNotifier
|
||||
@ -123,7 +128,7 @@ public:
|
||||
class CZMQPublishRawGovernanceObjectNotifier : public CZMQAbstractPublishNotifier
|
||||
{
|
||||
public:
|
||||
bool NotifyGovernanceObject(const std::shared_ptr<const CGovernanceObject>& object) override;
|
||||
bool NotifyGovernanceObject(const std::shared_ptr<const Governance::Object>& object) override;
|
||||
};
|
||||
|
||||
class CZMQPublishRawInstantSendDoubleSpendNotifier : public CZMQAbstractPublishNotifier
|
||||
|
@ -97,7 +97,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
|
||||
"spork -> validation -> spork"
|
||||
"governance/governance -> validation -> governance/governance"
|
||||
"evo/deterministicmns -> validationinterface -> governance/vote -> evo/deterministicmns"
|
||||
"governance/object -> validationinterface -> governance/object"
|
||||
"governance/vote -> validation -> validationinterface -> governance/vote"
|
||||
"llmq/signing -> masternode/node -> validationinterface -> llmq/signing"
|
||||
"evo/mnhftx -> validation -> evo/mnhftx"
|
||||
|
Loading…
Reference in New Issue
Block a user