mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Change CSigSharesInv and CBatchedSigShares to be sessionId based
This commit is contained in:
parent
2249413a7c
commit
80375a0b4f
@ -28,8 +28,6 @@ void CSigShare::UpdateKey()
|
||||
|
||||
void CSigSharesInv::Merge(const CSigSharesInv& inv2)
|
||||
{
|
||||
assert(llmqType == inv2.llmqType);
|
||||
assert(signHash == inv2.signHash);
|
||||
for (size_t i = 0; i < inv.size(); i++) {
|
||||
if (inv2.inv[i]) {
|
||||
inv[i] = inv2.inv[i];
|
||||
@ -44,7 +42,7 @@ size_t CSigSharesInv::CountSet() const
|
||||
|
||||
std::string CSigSharesInv::ToString() const
|
||||
{
|
||||
std::string str = strprintf("signHash=%s, inv=(", signHash.ToString());
|
||||
std::string str = "(";
|
||||
bool first = true;
|
||||
for (size_t i = 0; i < inv.size(); i++) {
|
||||
if (!inv[i]) {
|
||||
@ -61,11 +59,8 @@ std::string CSigSharesInv::ToString() const
|
||||
return str;
|
||||
}
|
||||
|
||||
void CSigSharesInv::Init(Consensus::LLMQType _llmqType, const uint256& _signHash)
|
||||
void CSigSharesInv::Init(Consensus::LLMQType _llmqType)
|
||||
{
|
||||
llmqType = _llmqType;
|
||||
signHash = _signHash;
|
||||
|
||||
size_t llmqSize = (size_t)(Params().GetConsensus().llmqs.at(_llmqType).size);
|
||||
inv.resize(llmqSize, false);
|
||||
}
|
||||
@ -82,6 +77,16 @@ void CSigSharesInv::Set(uint16_t quorumMember, bool v)
|
||||
inv[quorumMember] = v;
|
||||
}
|
||||
|
||||
CSigSharesInv CBatchedSigShares::ToInv(Consensus::LLMQType llmqType) const
|
||||
{
|
||||
CSigSharesInv inv;
|
||||
inv.Init(llmqType);
|
||||
for (size_t i = 0; i < sigShares.size(); i++) {
|
||||
inv.inv[sigShares[i].first] = true;
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
CSigSharesNodeState::Session& CSigSharesNodeState::GetOrCreateSession(Consensus::LLMQType llmqType, const uint256& signHash)
|
||||
{
|
||||
auto& s = sessions[signHash];
|
||||
@ -134,16 +139,6 @@ void CSigSharesNodeState::RemoveSession(const uint256& signHash)
|
||||
pendingIncomingSigShares.EraseAllForSignHash(signHash);
|
||||
}
|
||||
|
||||
CSigSharesInv CBatchedSigShares::ToInv() const
|
||||
{
|
||||
CSigSharesInv inv;
|
||||
inv.Init((Consensus::LLMQType)llmqType, CLLMQUtils::BuildSignHash(*this));
|
||||
for (size_t i = 0; i < sigShares.size(); i++) {
|
||||
inv.inv[sigShares[i].first] = true;
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
CSigSharesManager::CSigSharesManager()
|
||||
|
@ -59,8 +59,7 @@ public:
|
||||
class CSigSharesInv
|
||||
{
|
||||
public:
|
||||
uint8_t llmqType;
|
||||
uint256 signHash;
|
||||
uint32_t sessionId{(uint32_t)-1};
|
||||
std::vector<bool> inv;
|
||||
|
||||
public:
|
||||
@ -69,20 +68,14 @@ public:
|
||||
template<typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action)
|
||||
{
|
||||
READWRITE(llmqType);
|
||||
uint64_t invSize = inv.size();
|
||||
|
||||
auto& consensus = Params().GetConsensus();
|
||||
auto it = consensus.llmqs.find((Consensus::LLMQType)llmqType);
|
||||
if (it == consensus.llmqs.end()) {
|
||||
throw std::ios_base::failure("invalid llmqType");
|
||||
}
|
||||
const auto& params = it->second;
|
||||
|
||||
READWRITE(signHash);
|
||||
READWRITE(AUTOBITSET(inv, (size_t)params.size));
|
||||
READWRITE(VARINT(sessionId));
|
||||
READWRITE(COMPACTSIZE(invSize));
|
||||
READWRITE(AUTOBITSET(inv, (size_t)invSize));
|
||||
}
|
||||
|
||||
void Init(Consensus::LLMQType _llmqType, const uint256& _signHash);
|
||||
void Init(Consensus::LLMQType _llmqType);
|
||||
bool IsSet(uint16_t quorumMember) const;
|
||||
void Set(uint16_t quorumMember, bool v);
|
||||
void Merge(const CSigSharesInv& inv2);
|
||||
@ -95,10 +88,7 @@ public:
|
||||
class CBatchedSigShares
|
||||
{
|
||||
public:
|
||||
uint8_t llmqType;
|
||||
uint256 quorumHash;
|
||||
uint256 id;
|
||||
uint256 msgHash;
|
||||
uint32_t sessionId{(uint32_t)-1};
|
||||
std::vector<std::pair<uint16_t, CBLSLazySignature>> sigShares;
|
||||
|
||||
public:
|
||||
@ -107,10 +97,7 @@ public:
|
||||
template<typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action)
|
||||
{
|
||||
READWRITE(llmqType);
|
||||
READWRITE(quorumHash);
|
||||
READWRITE(id);
|
||||
READWRITE(msgHash);
|
||||
READWRITE(VARINT(sessionId));
|
||||
READWRITE(sigShares);
|
||||
}
|
||||
|
||||
@ -129,7 +116,7 @@ public:
|
||||
return sigShare;
|
||||
}
|
||||
|
||||
CSigSharesInv ToInv() const;
|
||||
CSigSharesInv ToInv(Consensus::LLMQType llmqType) const;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user