Skip to content

Commit 80375a0

Browse files
committed
Change CSigSharesInv and CBatchedSigShares to be sessionId based
1 parent 2249413 commit 80375a0

File tree

2 files changed

+21
-39
lines changed

2 files changed

+21
-39
lines changed

src/llmq/quorums_signing_shares.cpp

+12-17
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ void CSigShare::UpdateKey()
2828

2929
void CSigSharesInv::Merge(const CSigSharesInv& inv2)
3030
{
31-
assert(llmqType == inv2.llmqType);
32-
assert(signHash == inv2.signHash);
3331
for (size_t i = 0; i < inv.size(); i++) {
3432
if (inv2.inv[i]) {
3533
inv[i] = inv2.inv[i];
@@ -44,7 +42,7 @@ size_t CSigSharesInv::CountSet() const
4442

4543
std::string CSigSharesInv::ToString() const
4644
{
47-
std::string str = strprintf("signHash=%s, inv=(", signHash.ToString());
45+
std::string str = "(";
4846
bool first = true;
4947
for (size_t i = 0; i < inv.size(); i++) {
5048
if (!inv[i]) {
@@ -61,11 +59,8 @@ std::string CSigSharesInv::ToString() const
6159
return str;
6260
}
6361

64-
void CSigSharesInv::Init(Consensus::LLMQType _llmqType, const uint256& _signHash)
62+
void CSigSharesInv::Init(Consensus::LLMQType _llmqType)
6563
{
66-
llmqType = _llmqType;
67-
signHash = _signHash;
68-
6964
size_t llmqSize = (size_t)(Params().GetConsensus().llmqs.at(_llmqType).size);
7065
inv.resize(llmqSize, false);
7166
}
@@ -82,6 +77,16 @@ void CSigSharesInv::Set(uint16_t quorumMember, bool v)
8277
inv[quorumMember] = v;
8378
}
8479

80+
CSigSharesInv CBatchedSigShares::ToInv(Consensus::LLMQType llmqType) const
81+
{
82+
CSigSharesInv inv;
83+
inv.Init(llmqType);
84+
for (size_t i = 0; i < sigShares.size(); i++) {
85+
inv.inv[sigShares[i].first] = true;
86+
}
87+
return inv;
88+
}
89+
8590
CSigSharesNodeState::Session& CSigSharesNodeState::GetOrCreateSession(Consensus::LLMQType llmqType, const uint256& signHash)
8691
{
8792
auto& s = sessions[signHash];
@@ -134,16 +139,6 @@ void CSigSharesNodeState::RemoveSession(const uint256& signHash)
134139
pendingIncomingSigShares.EraseAllForSignHash(signHash);
135140
}
136141

137-
CSigSharesInv CBatchedSigShares::ToInv() const
138-
{
139-
CSigSharesInv inv;
140-
inv.Init((Consensus::LLMQType)llmqType, CLLMQUtils::BuildSignHash(*this));
141-
for (size_t i = 0; i < sigShares.size(); i++) {
142-
inv.inv[sigShares[i].first] = true;
143-
}
144-
return inv;
145-
}
146-
147142
//////////////////////
148143

149144
CSigSharesManager::CSigSharesManager()

src/llmq/quorums_signing_shares.h

+9-22
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ class CSigShare
5959
class CSigSharesInv
6060
{
6161
public:
62-
uint8_t llmqType;
63-
uint256 signHash;
62+
uint32_t sessionId{(uint32_t)-1};
6463
std::vector<bool> inv;
6564

6665
public:
@@ -69,20 +68,14 @@ class CSigSharesInv
6968
template<typename Stream, typename Operation>
7069
inline void SerializationOp(Stream& s, Operation ser_action)
7170
{
72-
READWRITE(llmqType);
73-
74-
auto& consensus = Params().GetConsensus();
75-
auto it = consensus.llmqs.find((Consensus::LLMQType)llmqType);
76-
if (it == consensus.llmqs.end()) {
77-
throw std::ios_base::failure("invalid llmqType");
78-
}
79-
const auto& params = it->second;
71+
uint64_t invSize = inv.size();
8072

81-
READWRITE(signHash);
82-
READWRITE(AUTOBITSET(inv, (size_t)params.size));
73+
READWRITE(VARINT(sessionId));
74+
READWRITE(COMPACTSIZE(invSize));
75+
READWRITE(AUTOBITSET(inv, (size_t)invSize));
8376
}
8477

85-
void Init(Consensus::LLMQType _llmqType, const uint256& _signHash);
78+
void Init(Consensus::LLMQType _llmqType);
8679
bool IsSet(uint16_t quorumMember) const;
8780
void Set(uint16_t quorumMember, bool v);
8881
void Merge(const CSigSharesInv& inv2);
@@ -95,10 +88,7 @@ class CSigSharesInv
9588
class CBatchedSigShares
9689
{
9790
public:
98-
uint8_t llmqType;
99-
uint256 quorumHash;
100-
uint256 id;
101-
uint256 msgHash;
91+
uint32_t sessionId{(uint32_t)-1};
10292
std::vector<std::pair<uint16_t, CBLSLazySignature>> sigShares;
10393

10494
public:
@@ -107,10 +97,7 @@ class CBatchedSigShares
10797
template<typename Stream, typename Operation>
10898
inline void SerializationOp(Stream& s, Operation ser_action)
10999
{
110-
READWRITE(llmqType);
111-
READWRITE(quorumHash);
112-
READWRITE(id);
113-
READWRITE(msgHash);
100+
READWRITE(VARINT(sessionId));
114101
READWRITE(sigShares);
115102
}
116103

@@ -129,7 +116,7 @@ class CBatchedSigShares
129116
return sigShare;
130117
}
131118

132-
CSigSharesInv ToInv() const;
119+
CSigSharesInv ToInv(Consensus::LLMQType llmqType) const;
133120
};
134121

135122
template<typename T>

0 commit comments

Comments
 (0)