mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
apply suggestions
This commit is contained in:
parent
600dcf3dda
commit
ad35c1ab2f
@ -164,7 +164,7 @@ int CQuorum::GetMemberIndex(const uint256& proTxHash) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CQuorum::WriteContributions(const std::unique_ptr<CDBWrapper>& db) const
|
void CQuorum::WriteContributions(CDBWrapper& db) const
|
||||||
{
|
{
|
||||||
uint256 dbKey = MakeQuorumKey(*this);
|
uint256 dbKey = MakeQuorumKey(*this);
|
||||||
|
|
||||||
@ -175,19 +175,19 @@ void CQuorum::WriteContributions(const std::unique_ptr<CDBWrapper>& db) const
|
|||||||
for (auto& pubkey : *quorumVvec) {
|
for (auto& pubkey : *quorumVvec) {
|
||||||
s << CBLSPublicKeyVersionWrapper(pubkey, false);
|
s << CBLSPublicKeyVersionWrapper(pubkey, false);
|
||||||
}
|
}
|
||||||
db->Write(std::make_pair(DB_QUORUM_QUORUM_VVEC, dbKey), s);
|
db.Write(std::make_pair(DB_QUORUM_QUORUM_VVEC, dbKey), s);
|
||||||
}
|
}
|
||||||
if (skShare.IsValid()) {
|
if (skShare.IsValid()) {
|
||||||
db->Write(std::make_pair(DB_QUORUM_SK_SHARE, dbKey), skShare);
|
db.Write(std::make_pair(DB_QUORUM_SK_SHARE, dbKey), skShare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CQuorum::ReadContributions(const std::unique_ptr<CDBWrapper>& db)
|
bool CQuorum::ReadContributions(const CDBWrapper& db)
|
||||||
{
|
{
|
||||||
uint256 dbKey = MakeQuorumKey(*this);
|
uint256 dbKey = MakeQuorumKey(*this);
|
||||||
CDataStream s(SER_DISK, CLIENT_VERSION);
|
CDataStream s(SER_DISK, CLIENT_VERSION);
|
||||||
|
|
||||||
if (!db->ReadDataStream(std::make_pair(DB_QUORUM_QUORUM_VVEC, dbKey), s)) {
|
if (!db.ReadDataStream(std::make_pair(DB_QUORUM_QUORUM_VVEC, dbKey), s)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ bool CQuorum::ReadContributions(const std::unique_ptr<CDBWrapper>& db)
|
|||||||
quorumVvec = std::make_shared<std::vector<CBLSPublicKey>>(std::move(qv));
|
quorumVvec = std::make_shared<std::vector<CBLSPublicKey>>(std::move(qv));
|
||||||
// We ignore the return value here as it is ok if this fails. If it fails, it usually means that we are not a
|
// We ignore the return value here as it is ok if this fails. If it fails, it usually means that we are not a
|
||||||
// member of the quorum but observed the whole DKG process to have the quorum verification vector.
|
// member of the quorum but observed the whole DKG process to have the quorum verification vector.
|
||||||
db->Read(std::make_pair(DB_QUORUM_SK_SHARE, dbKey), skShare);
|
db.Read(std::make_pair(DB_QUORUM_SK_SHARE, dbKey), skShare);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,8 @@ CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate,
|
|||||||
CQuorumBlockProcessor& _quorumBlockProcessor,
|
CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||||
const CSporkManager& sporkman, bool unit_tests, bool wipe) :
|
const CSporkManager& sporkman, bool unit_tests, bool wipe) :
|
||||||
db(std::make_unique<CDBWrapper>(unit_tests ? "" : (gArgs.GetDataDirNet() / "llmq/quorumdb"), 1 << 20, unit_tests, wipe)),
|
db(std::make_unique<CDBWrapper>(unit_tests ? "" : (gArgs.GetDataDirNet() / "llmq" / "quorumdb"), 1 << 20,
|
||||||
|
unit_tests, wipe)),
|
||||||
blsWorker(_blsWorker),
|
blsWorker(_blsWorker),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
connman(_connman),
|
connman(_connman),
|
||||||
@ -407,11 +408,11 @@ CQuorumPtr CQuorumManager::BuildQuorumFromCommitment(const Consensus::LLMQType l
|
|||||||
quorum->Init(std::move(qc), pQuorumBaseBlockIndex, minedBlockHash, members);
|
quorum->Init(std::move(qc), pQuorumBaseBlockIndex, minedBlockHash, members);
|
||||||
|
|
||||||
bool hasValidVvec = false;
|
bool hasValidVvec = false;
|
||||||
if (WITH_LOCK(cs_db, return quorum->ReadContributions(db))) {
|
if (WITH_LOCK(cs_db, return quorum->ReadContributions(*db))) {
|
||||||
hasValidVvec = true;
|
hasValidVvec = true;
|
||||||
} else {
|
} else {
|
||||||
if (BuildQuorumContributions(quorum->qc, quorum)) {
|
if (BuildQuorumContributions(quorum->qc, quorum)) {
|
||||||
WITH_LOCK(cs_db, quorum->WriteContributions(db));
|
WITH_LOCK(cs_db, quorum->WriteContributions(*db));
|
||||||
hasValidVvec = true;
|
hasValidVvec = true;
|
||||||
} else {
|
} else {
|
||||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- llmqType[%d] quorumIndex[%d] quorum.ReadContributions and BuildQuorumContributions for quorumHash[%s] failed\n", __func__, ToUnderlying(llmqType), quorum->qc->quorumIndex, quorum->qc->quorumHash.ToString());
|
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- llmqType[%d] quorumIndex[%d] quorum.ReadContributions and BuildQuorumContributions for quorumHash[%s] failed\n", __func__, ToUnderlying(llmqType), quorum->qc->quorumIndex, quorum->qc->quorumHash.ToString());
|
||||||
@ -849,7 +850,7 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, const std::string& msg_t
|
|||||||
return errorHandler("Invalid secret key share received");
|
return errorHandler("Invalid secret key share received");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WITH_LOCK(cs_db, pQuorum->WriteContributions(db));
|
WITH_LOCK(cs_db, pQuorum->WriteContributions(*db));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@ -1110,6 +1111,7 @@ void CQuorumManager::StartCleanupOldQuorumDataThread(const CBlockIndex* pIndex)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove in v23
|
||||||
void CQuorumManager::MigrateOldQuorumDB(CEvoDB& evoDb) const
|
void CQuorumManager::MigrateOldQuorumDB(CEvoDB& evoDb) const
|
||||||
{
|
{
|
||||||
LOCK(cs_db);
|
LOCK(cs_db);
|
||||||
@ -1117,7 +1119,7 @@ void CQuorumManager::MigrateOldQuorumDB(CEvoDB& evoDb) const
|
|||||||
|
|
||||||
const auto prefixes = {DB_QUORUM_QUORUM_VVEC, DB_QUORUM_SK_SHARE};
|
const auto prefixes = {DB_QUORUM_QUORUM_VVEC, DB_QUORUM_SK_SHARE};
|
||||||
|
|
||||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%d -- start\n", __func__);
|
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- start\n", __func__);
|
||||||
|
|
||||||
CDBBatch batch(*db);
|
CDBBatch batch(*db);
|
||||||
std::unique_ptr<CDBIterator> pcursor(evoDb.GetRawDB().NewIterator());
|
std::unique_ptr<CDBIterator> pcursor(evoDb.GetRawDB().NewIterator());
|
||||||
@ -1160,7 +1162,7 @@ void CQuorumManager::MigrateOldQuorumDB(CEvoDB& evoDb) const
|
|||||||
|
|
||||||
db->WriteBatch(batch);
|
db->WriteBatch(batch);
|
||||||
|
|
||||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%d -- %s moved %d\n", __func__, prefix, count);
|
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- %s moved %d\n", __func__, prefix, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pcursor.reset();
|
pcursor.reset();
|
||||||
@ -1169,7 +1171,7 @@ void CQuorumManager::MigrateOldQuorumDB(CEvoDB& evoDb) const
|
|||||||
DataCleanupHelper(evoDb.GetRawDB(), {});
|
DataCleanupHelper(evoDb.GetRawDB(), {});
|
||||||
evoDb.CommitRootTransaction();
|
evoDb.CommitRootTransaction();
|
||||||
|
|
||||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%d -- done\n", __func__);
|
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- done\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, const CChain& active_chain, const CQuorumManager& qman,
|
CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, const CChain& active_chain, const CQuorumManager& qman,
|
||||||
|
@ -217,8 +217,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool HasVerificationVectorInternal() const EXCLUSIVE_LOCKS_REQUIRED(cs_vvec_shShare);
|
bool HasVerificationVectorInternal() const EXCLUSIVE_LOCKS_REQUIRED(cs_vvec_shShare);
|
||||||
void WriteContributions(const std::unique_ptr<CDBWrapper>& db) const;
|
void WriteContributions(CDBWrapper& db) const;
|
||||||
bool ReadContributions(const std::unique_ptr<CDBWrapper>& db);
|
bool ReadContributions(const CDBWrapper& db);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user