mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
refactor: remove dependency of dkgsessionmgr on dkgsession
This commit is contained in:
parent
d361b11e5b
commit
d26d4ab0bc
@ -52,6 +52,8 @@ CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chai
|
||||
}
|
||||
}
|
||||
|
||||
CDKGSessionHandler::~CDKGSessionHandler() = default;
|
||||
|
||||
void CDKGPendingMessages::PushPendingMessage(NodeId from, PeerManager* peerman, CDataStream& vRecv)
|
||||
{
|
||||
// if peer is not -1 we should always pass valid peerman
|
||||
@ -589,4 +591,48 @@ void CDKGSessionHandler::PhaseHandlerThread()
|
||||
}
|
||||
}
|
||||
|
||||
bool CDKGSessionHandler::GetContribution(const uint256& hash, CDKGContribution& ret) const
|
||||
{
|
||||
LOCK(curSession->invCs);
|
||||
auto it = curSession->contributions.find(hash);
|
||||
if (it != curSession->contributions.end()) {
|
||||
ret = it->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDKGSessionHandler::GetComplaint(const uint256& hash, CDKGComplaint& ret) const
|
||||
{
|
||||
LOCK(curSession->invCs);
|
||||
auto it = curSession->complaints.find(hash);
|
||||
if (it != curSession->complaints.end()) {
|
||||
ret = it->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDKGSessionHandler::GetJustification(const uint256& hash, CDKGJustification& ret) const
|
||||
{
|
||||
LOCK(curSession->invCs);
|
||||
auto it = curSession->justifications.find(hash);
|
||||
if (it != curSession->justifications.end()) {
|
||||
ret = it->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDKGSessionHandler::GetPrematureCommitment(const uint256& hash, CDKGPrematureCommitment& ret) const
|
||||
{
|
||||
LOCK(curSession->invCs);
|
||||
auto it = curSession->prematureCommitments.find(hash);
|
||||
if (it != curSession->prematureCommitments.end() && curSession->validCommitments.count(hash)) {
|
||||
ret = it->second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace llmq
|
||||
|
@ -25,6 +25,10 @@ class PeerManager;
|
||||
|
||||
namespace llmq
|
||||
{
|
||||
class CDKGContribution;
|
||||
class CDKGComplaint;
|
||||
class CDKGJustification;
|
||||
class CDKGPrematureCommitment;
|
||||
class CDKGDebugManager;
|
||||
class CDKGSession;
|
||||
class CDKGSessionManager;
|
||||
@ -153,7 +157,7 @@ public:
|
||||
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman,
|
||||
CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman, const Consensus::LLMQParams& _params, int _quorumIndex);
|
||||
~CDKGSessionHandler() = default;
|
||||
~CDKGSessionHandler();
|
||||
|
||||
void UpdatedBlockTip(const CBlockIndex *pindexNew);
|
||||
void ProcessMessage(const CNode& pfrom, gsl::not_null<PeerManager*> peerman, const std::string& msg_type, CDataStream& vRecv);
|
||||
@ -161,6 +165,11 @@ public:
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
|
||||
bool GetContribution(const uint256& hash, CDKGContribution& ret) const;
|
||||
bool GetComplaint(const uint256& hash, CDKGComplaint& ret) const;
|
||||
bool GetJustification(const uint256& hash, CDKGJustification& ret) const;
|
||||
bool GetPrematureCommitment(const uint256& hash, CDKGPrematureCommitment& ret) const;
|
||||
|
||||
private:
|
||||
bool InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex);
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <llmq/debug.h>
|
||||
#include <llmq/dkgsession.h>
|
||||
#include <llmq/dkgsessionmgr.h>
|
||||
#include <llmq/options.h>
|
||||
#include <llmq/params.h>
|
||||
@ -300,10 +299,7 @@ bool CDKGSessionManager::GetContribution(const uint256& hash, CDKGContribution&
|
||||
if (dkgType.phase < QuorumPhase::Initialized || dkgType.phase > QuorumPhase::Contribute) {
|
||||
continue;
|
||||
}
|
||||
LOCK(dkgType.curSession->invCs);
|
||||
auto it = dkgType.curSession->contributions.find(hash);
|
||||
if (it != dkgType.curSession->contributions.end()) {
|
||||
ret = it->second;
|
||||
if (dkgType.GetContribution(hash, ret)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -321,10 +317,7 @@ bool CDKGSessionManager::GetComplaint(const uint256& hash, CDKGComplaint& ret) c
|
||||
if (dkgType.phase < QuorumPhase::Contribute || dkgType.phase > QuorumPhase::Complain) {
|
||||
continue;
|
||||
}
|
||||
LOCK(dkgType.curSession->invCs);
|
||||
auto it = dkgType.curSession->complaints.find(hash);
|
||||
if (it != dkgType.curSession->complaints.end()) {
|
||||
ret = it->second;
|
||||
if (dkgType.GetComplaint(hash, ret)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -342,10 +335,7 @@ bool CDKGSessionManager::GetJustification(const uint256& hash, CDKGJustification
|
||||
if (dkgType.phase < QuorumPhase::Complain || dkgType.phase > QuorumPhase::Justify) {
|
||||
continue;
|
||||
}
|
||||
LOCK(dkgType.curSession->invCs);
|
||||
auto it = dkgType.curSession->justifications.find(hash);
|
||||
if (it != dkgType.curSession->justifications.end()) {
|
||||
ret = it->second;
|
||||
if (dkgType.GetJustification(hash, ret)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -363,10 +353,7 @@ bool CDKGSessionManager::GetPrematureCommitment(const uint256& hash, CDKGPrematu
|
||||
if (dkgType.phase < QuorumPhase::Justify || dkgType.phase > QuorumPhase::Commit) {
|
||||
continue;
|
||||
}
|
||||
LOCK(dkgType.curSession->invCs);
|
||||
auto it = dkgType.curSession->prematureCommitments.find(hash);
|
||||
if (it != dkgType.curSession->prematureCommitments.end() && dkgType.curSession->validCommitments.count(hash)) {
|
||||
ret = it->second;
|
||||
if (dkgType.GetPrematureCommitment(hash, ret)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
|
||||
"banman -> bloom -> evo/assetlocktx -> llmq/quorums -> net -> banman"
|
||||
"banman -> bloom -> evo/assetlocktx -> llmq/signing -> net_processing -> banman"
|
||||
|
||||
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsession"
|
||||
"llmq/chainlocks -> validation -> llmq/chainlocks"
|
||||
"coinjoin/coinjoin -> llmq/chainlocks -> net -> coinjoin/coinjoin"
|
||||
"evo/deterministicmns -> llmq/utils -> llmq/snapshot -> evo/simplifiedmns -> evo/deterministicmns"
|
||||
|
Loading…
Reference in New Issue
Block a user