Skip to content

Commit 51a83e7

Browse files
committed
fix: clang formatting and adjusting logs for BuildNewListFromBlock
1 parent 8e8d6eb commit 51a83e7

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

src/evo/specialtxman.cpp

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ bool CSpecialTxProcessor::CheckSpecialTx(const CTransaction& tx, const CBlockInd
153153
state);
154154
}
155155

156-
static void HandleQuorumCommitment(const llmq::CFinalCommitment& qc,
157-
const std::vector<CDeterministicMNCPtr>& members,
156+
static void HandleQuorumCommitment(const llmq::CFinalCommitment& qc, const std::vector<CDeterministicMNCPtr>& members,
158157
bool debugLogs, CDeterministicMNList& mnList)
159158
{
160159
for (size_t i = 0; i < members.size(); i++) {
@@ -172,10 +171,8 @@ static void HandleQuorumCommitment(const llmq::CFinalCommitment& qc,
172171
}
173172

174173
bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindexPrev,
175-
const CCoinsViewCache& view,
176-
bool debugLogs,
177-
BlockValidationState& state,
178-
CDeterministicMNList& mnListRet)
174+
const CCoinsViewCache& view, bool debugLogs,
175+
BlockValidationState& state, CDeterministicMNList& mnListRet)
179176
{
180177
AssertLockHeld(cs_main);
181178

@@ -239,7 +236,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
239236

240237
Coin coin;
241238
CAmount expectedCollateral = GetMnType(proTx.nType).collat_amount;
242-
if (!proTx.collateralOutpoint.hash.IsNull() && (!view.GetCoin(dmn->collateralOutpoint, coin) || coin.IsSpent() || coin.out.nValue != expectedCollateral)) {
239+
if (!proTx.collateralOutpoint.hash.IsNull() && (!view.GetCoin(dmn->collateralOutpoint, coin) ||
240+
coin.IsSpent() || coin.out.nValue != expectedCollateral)) {
243241
// should actually never get to this point as CheckProRegTx should have handled this case.
244242
// We do this additional check nevertheless to be 100% sure
245243
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-protx-collateral");
@@ -252,8 +250,10 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
252250
// and the new one is added like a completely fresh one, which is also at the bottom of the payment list
253251
newList.RemoveMN(replacedDmn->proTxHash);
254252
if (debugLogs) {
255-
LogPrintf("CDeterministicMNManager::%s -- MN %s removed from list because collateral was used for a new ProRegTx. collateralOutpoint=%s, nHeight=%d, mapCurMNs.allMNsCount=%d\n",
256-
__func__, replacedDmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort(), nHeight, newList.GetAllMNsCount());
253+
LogPrintf("%s -- MN %s removed from list because collateral was used for " /* Continued */
254+
"a new ProRegTx. collateralOutpoint=%s, nHeight=%d, mapCurMNs.allMNsCount=%d\n",
255+
__func__, replacedDmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort(),
256+
nHeight, newList.GetAllMNsCount());
257257
}
258258
}
259259

@@ -284,8 +284,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
284284
newList.AddMN(dmn);
285285

286286
if (debugLogs) {
287-
LogPrintf("CDeterministicMNManager::%s -- MN %s added at height %d: %s\n",
288-
__func__, tx.GetHash().ToString(), nHeight, proTx.ToString());
287+
LogPrintf("%s -- MN %s added at height %d: %s\n", __func__, tx.GetHash().ToString(), nHeight,
288+
proTx.ToString());
289289
}
290290
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
291291
const auto opt_proTx = GetTxPayload<CProUpServTx>(tx);
@@ -334,16 +334,15 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
334334
!newState->keyIDOwner.IsNull()) {
335335
newState->Revive(nHeight);
336336
if (debugLogs) {
337-
LogPrintf("CDeterministicMNManager::%s -- MN %s revived at height %d\n",
338-
__func__, opt_proTx->proTxHash.ToString(), nHeight);
337+
LogPrintf("%s -- MN %s revived at height %d\n", __func__, opt_proTx->proTxHash.ToString(), nHeight);
339338
}
340339
}
341340
}
342341

343342
newList.UpdateMN(opt_proTx->proTxHash, newState);
344343
if (debugLogs) {
345-
LogPrintf("CDeterministicMNManager::%s -- MN %s updated at height %d: %s\n",
346-
__func__, opt_proTx->proTxHash.ToString(), nHeight, opt_proTx->ToString());
344+
LogPrintf("%s -- MN %s updated at height %d: %s\n", __func__, opt_proTx->proTxHash.ToString(), nHeight,
345+
opt_proTx->ToString());
347346
}
348347
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
349348
const auto opt_proTx = GetTxPayload<CProUpRegTx>(tx);
@@ -372,8 +371,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
372371
newList.UpdateMN(opt_proTx->proTxHash, newState);
373372

374373
if (debugLogs) {
375-
LogPrintf("CDeterministicMNManager::%s -- MN %s updated at height %d: %s\n",
376-
__func__, opt_proTx->proTxHash.ToString(), nHeight, opt_proTx->ToString());
374+
LogPrintf("%s -- MN %s updated at height %d: %s\n", __func__, opt_proTx->proTxHash.ToString(), nHeight,
375+
opt_proTx->ToString());
377376
}
378377
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
379378
const auto opt_proTx = GetTxPayload<CProUpRevTx>(tx);
@@ -393,8 +392,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
393392
newList.UpdateMN(opt_proTx->proTxHash, newState);
394393

395394
if (debugLogs) {
396-
LogPrintf("CDeterministicMNManager::%s -- MN %s revoked operator key at height %d: %s\n",
397-
__func__, opt_proTx->proTxHash.ToString(), nHeight, opt_proTx->ToString());
395+
LogPrintf("%s -- MN %s revoked operator key at height %d: %s\n", __func__,
396+
opt_proTx->proTxHash.ToString(), nHeight, opt_proTx->ToString());
398397
}
399398
} else if (tx.nType == TRANSACTION_QUORUM_COMMITMENT) {
400399
const auto opt_qc = GetTxPayload<llmq::CFinalCommitmentTxPayload>(tx);
@@ -407,7 +406,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
407406
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-qc-commitment-type");
408407
}
409408
int qcnHeight = int(opt_qc->nHeight);
410-
int quorumHeight = qcnHeight - (qcnHeight % llmq_params_opt->dkgInterval) + int(opt_qc->commitment.quorumIndex);
409+
int quorumHeight = qcnHeight - (qcnHeight % llmq_params_opt->dkgInterval) +
410+
int(opt_qc->commitment.quorumIndex);
411411
auto pQuorumBaseBlockIndex = pindexPrev->GetAncestor(quorumHeight);
412412
if (!pQuorumBaseBlockIndex || pQuorumBaseBlockIndex->GetBlockHash() != opt_qc->commitment.quorumHash) {
413413
// we should actually never get into this case as validation should have caught it...but let's be sure
@@ -416,7 +416,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
416416

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

419-
const auto members = llmq::utils::GetAllQuorumMembers(opt_qc->commitment.llmqType, m_dmnman, m_qsnapman, pQuorumBaseBlockIndex);
419+
const auto members = llmq::utils::GetAllQuorumMembers(opt_qc->commitment.llmqType, m_dmnman, m_qsnapman,
420+
pQuorumBaseBlockIndex);
420421
HandleQuorumCommitment(opt_qc->commitment, members, debugLogs, newList);
421422
}
422423
}
@@ -433,8 +434,10 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
433434
newList.RemoveMN(dmn->proTxHash);
434435

435436
if (debugLogs) {
436-
LogPrintf("CDeterministicMNManager::%s -- MN %s removed from list because collateral was spent. collateralOutpoint=%s, nHeight=%d, mapCurMNs.allMNsCount=%d\n",
437-
__func__, dmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort(), nHeight, newList.GetAllMNsCount());
437+
LogPrintf("%s -- MN %s removed from list because collateral was spent. " /* Continued */
438+
"collateralOutpoint=%s, nHeight=%d, mapCurMNs.allMNsCount=%d\n",
439+
__func__, dmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort(), nHeight,
440+
newList.GetAllMNsCount());
438441
}
439442
}
440443
}
@@ -451,8 +454,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
451454
if (dmn->nType == MnType::Evo && !isMNRewardReallocation) {
452455
++newState->nConsecutivePayments;
453456
if (debugLogs) {
454-
LogPrint(BCLog::MNPAYMENTS, "CDeterministicMNManager::%s -- MN %s is an EvoNode, bumping nConsecutivePayments to %d\n",
455-
__func__, dmn->proTxHash.ToString(), newState->nConsecutivePayments);
457+
LogPrint(BCLog::MNPAYMENTS, "%s -- MN %s is an EvoNode, bumping nConsecutivePayments to %d\n", __func__,
458+
dmn->proTxHash.ToString(), newState->nConsecutivePayments);
456459
}
457460
}
458461
newList.UpdateMN(payee->proTxHash, newState);
@@ -461,8 +464,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
461464
// Since the previous GetMN query returned a value, after an update, querying the same
462465
// hash *must* give us a result. If it doesn't, that would be a potential logic bug.
463466
assert(dmn);
464-
LogPrint(BCLog::MNPAYMENTS, "CDeterministicMNManager::%s -- MN %s, nConsecutivePayments=%d\n",
465-
__func__, dmn->proTxHash.ToString(), dmn->pdmnState->nConsecutivePayments);
467+
LogPrint(BCLog::MNPAYMENTS, "%s -- MN %s, nConsecutivePayments=%d\n", __func__, dmn->proTxHash.ToString(),
468+
dmn->pdmnState->nConsecutivePayments);
466469
}
467470
}
468471

@@ -473,8 +476,8 @@ bool CSpecialTxProcessor::BuildNewListFromBlock(const CBlock& block, gsl::not_nu
473476
if (payee != nullptr && dmn.proTxHash == payee->proTxHash && !isMNRewardReallocation) return;
474477
if (dmn.pdmnState->nConsecutivePayments == 0) return;
475478
if (debugLogs) {
476-
LogPrint(BCLog::MNPAYMENTS, "CDeterministicMNManager::%s -- MN %s, reset nConsecutivePayments %d->0\n",
477-
__func__, dmn.proTxHash.ToString(), dmn.pdmnState->nConsecutivePayments);
479+
LogPrint(BCLog::MNPAYMENTS, "%s -- MN %s, reset nConsecutivePayments %d->0\n", __func__,
480+
dmn.proTxHash.ToString(), dmn.pdmnState->nConsecutivePayments);
478481
}
479482
auto newState = std::make_shared<CDeterministicMNState>(*dmn.pdmnState);
480483
newState->nConsecutivePayments = 0;

src/evo/specialtxman.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#ifndef BITCOIN_EVO_SPECIALTXMAN_H
66
#define BITCOIN_EVO_SPECIALTXMAN_H
77

8-
#include <sync.h>
9-
#include <threadsafety.h>
108
#include <gsl/pointers.h>
119
#include <optional>
10+
#include <sync.h>
11+
#include <threadsafety.h>
1212

1313
class BlockValidationState;
1414
class CBlock;
@@ -75,8 +75,9 @@ class CSpecialTxProcessor
7575

7676
// the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet)
7777
bool BuildNewListFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindexPrev,
78-
const CCoinsViewCache& view, bool debugLogs,
79-
BlockValidationState& state, CDeterministicMNList& mnListRet) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
78+
const CCoinsViewCache& view, bool debugLogs, BlockValidationState& state,
79+
CDeterministicMNList& mnListRet) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
80+
8081
private:
8182
bool CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CCbTx& cbTx,
8283
BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

0 commit comments

Comments
 (0)