Skip to content

Commit 7c1dc2d

Browse files
committed
lint: apply most clang-format suggestions
1 parent 3ba6daa commit 7c1dc2d

File tree

8 files changed

+182
-127
lines changed

8 files changed

+182
-127
lines changed

src/evo/specialtxman.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,9 @@ bool CSpecialTxProcessor::RebuildListFromBlock(const CBlock& block, gsl::not_nul
442442

443443
// The commitment has already been validated at this point, so it's safe to use members of it
444444

445-
const auto members = llmq::utils::GetAllQuorumMembers(opt_qc->commitment.llmqType, {m_dmnman, m_qsnapman, m_chainman, pQuorumBaseBlockIndex});
445+
const auto members = llmq::utils::GetAllQuorumMembers(opt_qc->commitment.llmqType,
446+
{m_dmnman, m_qsnapman, m_chainman,
447+
pQuorumBaseBlockIndex});
446448
HandleQuorumCommitment(opt_qc->commitment, members, debugLogs, newList);
447449
}
448450
}

src/llmq/commitment.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ CFinalCommitment::CFinalCommitment(const Consensus::LLMQParams& params, const ui
2828
{
2929
}
3030

31-
bool CFinalCommitment::VerifySignatureAsync(const llmq::UtilParameters& util_params, CCheckQueueControl<utils::BlsCheck>* queue_control) const
31+
bool CFinalCommitment::VerifySignatureAsync(const llmq::UtilParameters& util_params,
32+
CCheckQueueControl<utils::BlsCheck>* queue_control) const
3233
{
3334
auto members = utils::GetAllQuorumMembers(llmqType, util_params);
3435
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
@@ -102,8 +103,10 @@ bool CFinalCommitment::Verify(const llmq::UtilParameters& util_params, bool chec
102103
}
103104
const auto& llmq_params = llmq_params_opt.value();
104105

105-
const uint16_t expected_nversion{CFinalCommitment::GetVersion(IsQuorumRotationEnabled(llmq_params, util_params.m_base_index),
106-
DeploymentActiveAfter(util_params.m_base_index, util_params.m_chainman.GetConsensus(), Consensus::DEPLOYMENT_V19))};
106+
const uint16_t expected_nversion{
107+
CFinalCommitment::GetVersion(IsQuorumRotationEnabled(llmq_params, util_params.m_base_index),
108+
DeploymentActiveAfter(util_params.m_base_index, util_params.m_chainman.GetConsensus(),
109+
Consensus::DEPLOYMENT_V19))};
107110
if (nVersion == 0 || nVersion != expected_nversion) {
108111
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid nVersion=%d expected=%d\n", quorumHash.ToString(), nVersion, expected_nversion);
109112
return false;
@@ -214,14 +217,16 @@ bool CheckLLMQCommitment(const llmq::UtilParameters& util_params, const CTransac
214217
{
215218
const auto opt_qcTx = GetTxPayload<CFinalCommitmentTxPayload>(tx);
216219
if (!opt_qcTx) {
217-
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] GetTxPayload LLMQCommitment failed\n", util_params.m_base_index->nHeight);
220+
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] GetTxPayload LLMQCommitment failed\n",
221+
util_params.m_base_index->nHeight);
218222
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-payload");
219223
}
220224
auto& qcTx = *opt_qcTx;
221225

222226
const auto& llmq_params_opt = Params().GetLLMQ(qcTx.commitment.llmqType);
223227
if (!llmq_params_opt.has_value()) {
224-
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] GetLLMQ failed for llmqType[%d]\n", util_params.m_base_index->nHeight, ToUnderlying(qcTx.commitment.llmqType));
228+
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] GetLLMQ failed for llmqType[%d]\n",
229+
util_params.m_base_index->nHeight, ToUnderlying(qcTx.commitment.llmqType));
225230
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-commitment-type");
226231
}
227232

@@ -235,16 +240,19 @@ bool CheckLLMQCommitment(const llmq::UtilParameters& util_params, const CTransac
235240
}
236241

237242
if (qcTx.nVersion == 0 || qcTx.nVersion > CFinalCommitmentTxPayload::CURRENT_VERSION) {
238-
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.nVersion[%d]\n", util_params.m_base_index->nHeight, qcTx.nVersion);
243+
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.nVersion[%d]\n",
244+
util_params.m_base_index->nHeight, qcTx.nVersion);
239245
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-version");
240246
}
241247

242248
if (qcTx.nHeight != uint32_t(util_params.m_base_index->nHeight + 1)) {
243-
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.nHeight[%d]\n", util_params.m_base_index->nHeight, qcTx.nHeight);
249+
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.nHeight[%d]\n", util_params.m_base_index->nHeight,
250+
qcTx.nHeight);
244251
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-height");
245252
}
246253

247-
const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(::cs_main, return util_params.m_chainman.m_blockman.LookupBlockIndex(qcTx.commitment.quorumHash));
254+
const CBlockIndex* pQuorumBaseBlockIndex =
255+
WITH_LOCK(::cs_main, return util_params.m_chainman.m_blockman.LookupBlockIndex(qcTx.commitment.quorumHash));
248256
if (pQuorumBaseBlockIndex == nullptr) {
249257
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-quorum-hash");
250258
}
@@ -256,14 +264,16 @@ bool CheckLLMQCommitment(const llmq::UtilParameters& util_params, const CTransac
256264

257265
if (qcTx.commitment.IsNull()) {
258266
if (!qcTx.commitment.VerifyNull()) {
259-
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] VerifyNull failed\n", util_params.m_base_index->nHeight, qcTx.commitment.quorumHash.ToString());
267+
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] VerifyNull failed\n",
268+
util_params.m_base_index->nHeight, qcTx.commitment.quorumHash.ToString());
260269
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-invalid-null");
261270
}
262271
return true;
263272
}
264273

265274
if (!qcTx.commitment.Verify(util_params.replace_index(pQuorumBaseBlockIndex), false)) {
266-
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] Verify failed\n", util_params.m_base_index->nHeight, qcTx.commitment.quorumHash.ToString());
275+
LogPrint(BCLog::LLMQ, "CFinalCommitment -- h[%d] invalid qcTx.commitment[%s] Verify failed\n",
276+
util_params.m_base_index->nHeight, qcTx.commitment.quorumHash.ToString());
267277
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-invalid");
268278
}
269279

src/llmq/commitment.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class CFinalCommitment
7676
return int(std::count(validMembers.begin(), validMembers.end(), true));
7777
}
7878

79-
bool VerifySignatureAsync(const llmq::UtilParameters& util_params, CCheckQueueControl<utils::BlsCheck>* queue_control) const;
79+
bool VerifySignatureAsync(const llmq::UtilParameters& util_params,
80+
CCheckQueueControl<utils::BlsCheck>* queue_control) const;
8081
bool Verify(const llmq::UtilParameters& util_params, bool checkSigs) const;
8182
bool VerifyNull() const;
8283
bool VerifySizes(const Consensus::LLMQParams& params) const;

src/llmq/snapshot.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace {
1818
constexpr std::string_view DB_QUORUM_SNAPSHOT{"llmq_S"};
1919

2020
//! Constructs a llmq::CycleData and populate it with metadata
21-
std::optional<llmq::CycleData> ConstructCycle(llmq::CQuorumSnapshotManager& qsnapman, const Consensus::LLMQType& llmq_type,
22-
bool skip_snap, int32_t height, gsl::not_null<const CBlockIndex*> index_tip,
23-
std::string& error)
21+
std::optional<llmq::CycleData> ConstructCycle(llmq::CQuorumSnapshotManager& qsnapman,
22+
const Consensus::LLMQType& llmq_type, bool skip_snap, int32_t height,
23+
gsl::not_null<const CBlockIndex*> index_tip, std::string& error)
2424
{
2525
llmq::CycleData ret;
2626
ret.m_cycle_index = index_tip->GetAncestor(height);
@@ -108,14 +108,17 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan
108108

109109
const int cycleLength = llmq_params_opt->dkgInterval;
110110

111-
auto cycle_base_opt = ConstructCycle(qsnapman, llmqType, /*skip_snap=*/true, /*height=*/blockIndex->nHeight - (blockIndex->nHeight % cycleLength), blockIndex, errorRet);
111+
auto cycle_base_opt = ConstructCycle(qsnapman, llmqType, /*skip_snap=*/true,
112+
/*height=*/blockIndex->nHeight - (blockIndex->nHeight % cycleLength),
113+
blockIndex, errorRet);
112114
if (!cycle_base_opt.has_value()) {
113115
return false;
114116
}
115117
if (use_legacy_construction) {
116118
// Build MN list Diff always with highest baseblock
117119
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman,
118-
GetLastBaseBlockHash(baseBlockIndexes, cycle_base_opt->m_work_index, use_legacy_construction),
120+
GetLastBaseBlockHash(baseBlockIndexes, cycle_base_opt->m_work_index,
121+
use_legacy_construction),
119122
cycle_base_opt->m_work_index->GetBlockHash(), response.mnListDiffH, errorRet)) {
120123
return false;
121124
}
@@ -125,13 +128,16 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan
125128

126129
auto target_cycles{response.GetCycles()};
127130
for (size_t idx{0}; idx < target_cycles.size(); idx++) {
128-
auto cycle_opt = ConstructCycle(qsnapman, llmqType, /*skip_snap=*/false, /*height=*/cycle_base_opt->m_cycle_index->nHeight - (cycleLength * (idx + 1)), tipBlockIndex, errorRet);
131+
auto cycle_opt = ConstructCycle(qsnapman, llmqType, /*skip_snap=*/false,
132+
/*height=*/cycle_base_opt->m_cycle_index->nHeight - (cycleLength * (idx + 1)),
133+
tipBlockIndex, errorRet);
129134
if (!cycle_opt.has_value()) {
130135
return false;
131136
}
132137
if (use_legacy_construction) {
133138
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman,
134-
GetLastBaseBlockHash(baseBlockIndexes, cycle_opt->m_work_index, use_legacy_construction),
139+
GetLastBaseBlockHash(baseBlockIndexes, cycle_opt->m_work_index,
140+
use_legacy_construction),
135141
cycle_opt->m_work_index->GetBlockHash(), cycle_opt->m_diff, errorRet)) {
136142
return false;
137143
}
@@ -165,7 +171,8 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan
165171
response.quorumSnapshotList.push_back(cycle_opt->m_snap);
166172
CSimplifiedMNListDiff mnhneeded;
167173
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman,
168-
GetLastBaseBlockHash(baseBlockIndexes, cycle_opt->m_work_index, use_legacy_construction),
174+
GetLastBaseBlockHash(baseBlockIndexes, cycle_opt->m_work_index,
175+
use_legacy_construction),
169176
cycle_opt->m_work_index->GetBlockHash(), mnhneeded, errorRet)) {
170177
return false;
171178
}
@@ -179,16 +186,17 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan
179186
for (size_t idx = target_cycles.size(); idx-- > 0;) {
180187
auto* cycle{target_cycles[idx]};
181188
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman,
182-
GetLastBaseBlockHash(baseBlockIndexes, cycle->m_work_index, use_legacy_construction),
183-
cycle->m_work_index->GetBlockHash(), cycle->m_diff, errorRet))
184-
{
189+
GetLastBaseBlockHash(baseBlockIndexes, cycle->m_work_index,
190+
use_legacy_construction),
191+
cycle->m_work_index->GetBlockHash(), cycle->m_diff, errorRet)) {
185192
return false;
186193
}
187194
baseBlockIndexes.push_back(cycle->m_work_index);
188195
}
189196

190197
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman,
191-
GetLastBaseBlockHash(baseBlockIndexes, cycle_base_opt->m_work_index, use_legacy_construction),
198+
GetLastBaseBlockHash(baseBlockIndexes, cycle_base_opt->m_work_index,
199+
use_legacy_construction),
192200
cycle_base_opt->m_work_index->GetBlockHash(), response.mnListDiffH, errorRet)) {
193201
return false;
194202
}
@@ -282,5 +290,4 @@ void CQuorumSnapshotManager::StoreSnapshotForBlock(const Consensus::LLMQType llm
282290
m_evoDb.GetRawDB().Write(std::make_pair(DB_QUORUM_SNAPSHOT, snapshotHash), snapshot);
283291
quorumSnapshotCache.insert(snapshotHash, snapshot);
284292
}
285-
286293
} // namespace llmq

0 commit comments

Comments
 (0)