mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: move pQuorumBaseBlockIndex from Init() to constructor in CDKGSession
This commit is contained in:
parent
9f3eb6bbb8
commit
9593566802
@ -68,9 +68,8 @@ CDKGMember::CDKGMember(const CDeterministicMNCPtr& _dmn, size_t _idx) :
|
||||
|
||||
}
|
||||
|
||||
bool CDKGSession::Init(gsl::not_null<const CBlockIndex*> _pQuorumBaseBlockIndex, Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex)
|
||||
bool CDKGSession::Init(Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex)
|
||||
{
|
||||
m_quorum_base_block_index = _pQuorumBaseBlockIndex;
|
||||
quorumIndex = _quorumIndex;
|
||||
members.resize(mns.size());
|
||||
memberIds.resize(members.size());
|
||||
|
@ -288,7 +288,7 @@ private:
|
||||
const CActiveMasternodeManager* const m_mn_activeman;
|
||||
const CSporkManager& m_sporkman;
|
||||
|
||||
const CBlockIndex* m_quorum_base_block_index{nullptr};
|
||||
const CBlockIndex* const m_quorum_base_block_index;
|
||||
int quorumIndex{0};
|
||||
|
||||
private:
|
||||
@ -326,16 +326,17 @@ private:
|
||||
std::set<uint256> validCommitments GUARDED_BY(invCs);
|
||||
|
||||
public:
|
||||
CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CConnman& _connman,
|
||||
CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CConnman& _connman,
|
||||
CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager,
|
||||
CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CSporkManager& sporkman) :
|
||||
params(_params), blsWorker(_blsWorker), cache(_blsWorker), connman(_connman), m_dmnman(dmnman), dkgManager(_dkgManager),
|
||||
dkgDebugManager(_dkgDebugManager), m_mn_metaman(mn_metaman), m_mn_activeman(mn_activeman), m_sporkman(sporkman)
|
||||
dkgDebugManager(_dkgDebugManager), m_mn_metaman(mn_metaman), m_mn_activeman(mn_activeman), m_sporkman(sporkman),
|
||||
m_quorum_base_block_index{pQuorumBaseBlockIndex}
|
||||
{}
|
||||
|
||||
// TODO: remove Init completely
|
||||
bool Init(gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex);
|
||||
bool Init(Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex);
|
||||
|
||||
[[nodiscard]] std::optional<size_t> GetMyMemberIndex() const { return myIdx; }
|
||||
|
||||
|
@ -41,7 +41,7 @@ CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chai
|
||||
m_peerman(peerman),
|
||||
params(_params),
|
||||
quorumIndex(_quorumIndex),
|
||||
curSession(std::make_unique<CDKGSession>(_params, _blsWorker, _connman, dmnman, _dkgManager, _dkgDebugManager, m_mn_metaman, m_mn_activeman, sporkman)),
|
||||
curSession(std::make_unique<CDKGSession>(nullptr, _params, _blsWorker, _connman, dmnman, _dkgManager, _dkgDebugManager, m_mn_metaman, m_mn_activeman, sporkman)),
|
||||
pendingContributions((size_t)_params.size * 2, MSG_QUORUM_CONTRIB), // we allow size*2 messages as we need to make sure we see bad behavior (double messages)
|
||||
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT),
|
||||
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
|
||||
@ -194,10 +194,10 @@ bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
||||
return false;
|
||||
}
|
||||
|
||||
curSession = std::make_unique<CDKGSession>(params, blsWorker, connman, m_dmnman, dkgManager, dkgDebugManager, m_mn_metaman, m_mn_activeman, m_sporkman);
|
||||
|
||||
auto mns = utils::GetAllQuorumMembers(params.type, m_dmnman, pQuorumBaseBlockIndex);
|
||||
if (!curSession->Init(pQuorumBaseBlockIndex, mns, m_mn_activeman->GetProTxHash(), quorumIndex)) {
|
||||
curSession = std::make_unique<CDKGSession>(pQuorumBaseBlockIndex, params, blsWorker, connman, m_dmnman, dkgManager, dkgDebugManager, m_mn_metaman, m_mn_activeman, m_sporkman);
|
||||
|
||||
if (!curSession->Init(mns, m_mn_activeman->GetProTxHash(), quorumIndex)) {
|
||||
LogPrintf("CDKGSessionManager::%s -- height[%d] quorum initialization failed for %s qi[%d] mns[%d]\n", __func__, pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex, mns.size());
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user