Skip to content

Commit 2651885

Browse files
committed
fmt: clang-format for all changes in this PR
1 parent 38bfafa commit 2651885

File tree

18 files changed

+128
-126
lines changed

18 files changed

+128
-126
lines changed

src/active/context.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
#include <validationinterface.h>
2525

2626
ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman, CConnman& connman,
27-
CDeterministicMNManager& dmnman, CGovernanceManager& govman,
28-
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman, const chainlock::Chainlocks& chainlocks,
29-
CTxMemPool& mempool, chainlock::ChainlockHandler& clhandler, llmq::CInstantSendManager& isman,
30-
llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman,
31-
llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman,
32-
PeerManager& peerman, const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk,
33-
const llmq::QvvecSyncModeMap& sync_map, const util::DbWrapperParams& db_params,
34-
bool quorums_recovery, bool quorums_watch) :
27+
CDeterministicMNManager& dmnman, CGovernanceManager& govman, CMasternodeMetaMan& mn_metaman,
28+
CMNHFManager& mnhfman, CSporkManager& sporkman, const chainlock::Chainlocks& chainlocks,
29+
CTxMemPool& mempool, chainlock::ChainlockHandler& clhandler,
30+
llmq::CInstantSendManager& isman, llmq::CQuorumBlockProcessor& qblockman,
31+
llmq::CQuorumManager& qman, llmq::CQuorumSnapshotManager& qsnapman,
32+
llmq::CSigningManager& sigman, PeerManager& peerman, const CMasternodeSync& mn_sync,
33+
const CBLSSecretKey& operator_sk, const llmq::QvvecSyncModeMap& sync_map,
34+
const util::DbWrapperParams& db_params, bool quorums_recovery, bool quorums_watch) :
3535
m_isman{isman},
3636
m_qman{qman},
3737
nodeman{std::make_unique<CActiveMasternodeManager>(connman, dmnman, operator_sk)},
@@ -43,8 +43,8 @@ ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman
4343
ehf_sighandler{std::make_unique<llmq::CEHFSignalsHandler>(chainman, mnhfman, sigman, *shareman, qman)},
4444
qman_handler{std::make_unique<llmq::QuorumParticipant>(bls_worker, connman, dmnman, qman, qsnapman, *nodeman, chainman,
4545
mn_sync, sporkman, sync_map, quorums_recovery, quorums_watch)},
46-
cl_signer{std::make_unique<chainlock::ChainLockSigner>(chainman.ActiveChainstate(), chainlocks, clhandler, isman, qman, sigman, *shareman,
47-
mn_sync)},
46+
cl_signer{std::make_unique<chainlock::ChainLockSigner>(chainman.ActiveChainstate(), chainlocks, clhandler, isman,
47+
qman, sigman, *shareman, mn_sync)},
4848
is_signer{std::make_unique<instantsend::InstantSendSigner>(chainman.ActiveChainstate(), chainlocks, isman, sigman,
4949
*shareman, qman, sporkman, mempool, mn_sync)}
5050
{

src/active/context.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ struct ActiveContext final : public CValidationInterface {
6363
ActiveContext& operator=(const ActiveContext&) = delete;
6464
explicit ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman, CConnman& connman,
6565
CDeterministicMNManager& dmnman, CGovernanceManager& govman, CMasternodeMetaMan& mn_metaman,
66-
CMNHFManager& mnhfman, CSporkManager& sporkman, const chainlock::Chainlocks& chainlocks, CTxMemPool& mempool,
67-
chainlock::ChainlockHandler& clhandler, llmq::CInstantSendManager& isman,
68-
llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman,
69-
llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman, PeerManager& peerman,
70-
const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk,
71-
const llmq::QvvecSyncModeMap& sync_map, const util::DbWrapperParams& db_params,
72-
bool quorums_recovery, bool quorums_watch);
66+
CMNHFManager& mnhfman, CSporkManager& sporkman, const chainlock::Chainlocks& chainlocks,
67+
CTxMemPool& mempool, chainlock::ChainlockHandler& clhandler,
68+
llmq::CInstantSendManager& isman, llmq::CQuorumBlockProcessor& qblockman,
69+
llmq::CQuorumManager& qman, llmq::CQuorumSnapshotManager& qsnapman,
70+
llmq::CSigningManager& sigman, PeerManager& peerman, const CMasternodeSync& mn_sync,
71+
const CBLSSecretKey& operator_sk, const llmq::QvvecSyncModeMap& sync_map,
72+
const util::DbWrapperParams& db_params, bool quorums_recovery, bool quorums_watch);
7373
~ActiveContext();
7474

7575
void Interrupt();

src/chainlock/chainlock.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55
#include <chainlock/chainlock.h>
66

77
#include <chainlock/clsig.h>
8-
#include <spork.h>
98
#include <logging.h>
9+
#include <spork.h>
1010

11-
namespace chainlock
12-
{
13-
14-
Chainlocks::Chainlocks(const CSporkManager& sporkman) : m_sporks(sporkman) {}
11+
namespace chainlock {
1512

16-
bool Chainlocks::IsEnabled() const
13+
Chainlocks::Chainlocks(const CSporkManager& sporkman) :
14+
m_sporks(sporkman)
1715
{
18-
return m_sporks.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED);
1916
}
2017

21-
bool Chainlocks::IsSigningEnabled() const
22-
{
23-
return m_sporks.GetSporkValue(SPORK_19_CHAINLOCKS_ENABLED) == 0;
24-
}
18+
bool Chainlocks::IsEnabled() const { return m_sporks.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED); }
19+
20+
bool Chainlocks::IsSigningEnabled() const { return m_sporks.GetSporkValue(SPORK_19_CHAINLOCKS_ENABLED) == 0; }
2521

2622
chainlock::ChainLockSig Chainlocks::GetBestChainLock() const
2723
{
@@ -160,4 +156,4 @@ void Chainlocks::AcceptedBlockHeader(gsl::not_null<const CBlockIndex*> pindexNew
160156
bestChainLockBlockIndex = pindexNew;
161157
}
162158
}
163-
} // namespace chainlock::
159+
} // namespace chainlock

src/chainlock/chainlock.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
class CSporkManager;
1515

16-
namespace chainlock
17-
{
16+
namespace chainlock {
1817

1918
//! Depth of block including transactions before it's considered safe
2019
static constexpr int32_t TX_CONFIRM_THRESHOLD{5};
@@ -31,32 +30,28 @@ class Chainlocks
3130
chainlock::ChainLockSig bestChainLock GUARDED_BY(cs);
3231

3332
chainlock::ChainLockSig bestChainLockWithKnownBlock GUARDED_BY(cs);
34-
public:
3533

34+
public:
3635
Chainlocks(const CSporkManager& sporkman);
3736

3837
[[nodiscard]] bool IsEnabled() const;
3938
[[nodiscard]] bool IsSigningEnabled() const;
4039

41-
[[nodiscard]] chainlock::ChainLockSig GetBestChainLock() const
42-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
40+
[[nodiscard]] chainlock::ChainLockSig GetBestChainLock() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
4341

44-
[[nodiscard]] int32_t GetBestChainLockHeight() const
45-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
42+
[[nodiscard]] int32_t GetBestChainLockHeight() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
4643

47-
[[nodiscard]] bool HasChainLock(int nHeight, const uint256& blockHash) const
48-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
44+
[[nodiscard]] bool HasChainLock(int nHeight, const uint256& blockHash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
4945

50-
[[nodiscard]] bool HasConflictingChainLock(int nHeight, const uint256& blockHash) const
51-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
46+
[[nodiscard]] bool HasConflictingChainLock(int nHeight, const uint256& blockHash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
5247

53-
bool UpdateBestChainlock(const uint256& hash, const chainlock::ChainLockSig& clsig, const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs);
48+
bool UpdateBestChainlock(const uint256& hash, const chainlock::ChainLockSig& clsig, const CBlockIndex* pindex)
49+
EXCLUSIVE_LOCKS_REQUIRED(!cs);
5450

5551
std::pair<chainlock::ChainLockSig, const CBlockIndex*> GetBestChainlockWithPindex() const
5652
EXCLUSIVE_LOCKS_REQUIRED(!cs);
5753

58-
bool GetChainLockByHash(const uint256& hash, chainlock::ChainLockSig& ret) const
59-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
54+
bool GetChainLockByHash(const uint256& hash, chainlock::ChainLockSig& ret) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
6055

6156
void AcceptedBlockHeader(gsl::not_null<const CBlockIndex*> pindexNew) EXCLUSIVE_LOCKS_REQUIRED(!cs);
6257

src/chainlock/handler.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ static constexpr auto WAIT_FOR_ISLOCK_TIMEOUT{10min};
3636
} // anonymous namespace
3737

3838
namespace chainlock {
39-
ChainlockHandler::ChainlockHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
40-
CTxMemPool& _mempool, const CMasternodeSync& mn_sync) :
39+
ChainlockHandler::ChainlockHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman, CTxMemPool& _mempool,
40+
const CMasternodeSync& mn_sync) :
4141
m_chainlocks{chainlocks},
4242
m_chainman{chainman},
4343
mempool{_mempool},
@@ -65,10 +65,7 @@ void ChainlockHandler::Start()
6565
std::chrono::seconds{5});
6666
}
6767

68-
void ChainlockHandler::Stop()
69-
{
70-
scheduler->stop();
71-
}
68+
void ChainlockHandler::Stop() { scheduler->stop(); }
7269

7370
bool ChainlockHandler::AlreadyHave(const CInv& inv) const
7471
{
@@ -85,8 +82,8 @@ void ChainlockHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int6
8582
}
8683
}
8784

88-
MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
89-
const uint256& hash)
85+
MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from, const chainlock::ChainLockSig& clsig,
86+
const llmq::CQuorumManager& qman, const uint256& hash)
9087
{
9188
CheckActiveState();
9289

@@ -103,7 +100,8 @@ MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from,
103100
}
104101
}
105102

106-
if (const auto ret = chainlock::VerifyChainLock(Params().GetConsensus(), m_chainman.ActiveChain(), qman, clsig); ret != llmq::VerifyRecSigStatus::Valid) {
103+
if (const auto ret = chainlock::VerifyChainLock(Params().GetConsensus(), m_chainman.ActiveChain(), qman, clsig);
104+
ret != llmq::VerifyRecSigStatus::Valid) {
107105
LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- invalid CLSIG (%s), status=%d peer=%d\n", __func__,
108106
clsig.ToString(), ToUnderlying(ret), from);
109107
if (from != -1) {
@@ -131,15 +129,15 @@ MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from,
131129
return clsig_inv;
132130
}
133131

134-
void ChainlockHandler::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
132+
void ChainlockHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
135133
{
136134
if (pindexNew == pindexFork) // blocks were disconnected without any new ones
137135
return;
138136
if (fInitialDownload) return;
139137

140-
// TODO: reconsider removing scheduler from here, because UpdatedBlockTip is already async call from notification scheduler
141-
// don't call TrySignChainTip directly but instead let the scheduler call it. This way we ensure that cs_main is
142-
// never locked and TrySignChainTip is not called twice in parallel. Also avoids recursive calls due to
138+
// TODO: reconsider removing scheduler from here, because UpdatedBlockTip is already async call from notification
139+
// scheduler don't call TrySignChainTip directly but instead let the scheduler call it. This way we ensure that
140+
// cs_main is never locked and TrySignChainTip is not called twice in parallel. Also avoids recursive calls due to
143141
// EnforceBestChainLock switching chains.
144142
// atomic[If tryLockChainTipScheduled is false, do (set it to true] and schedule signing).
145143

@@ -253,8 +251,7 @@ void ChainlockHandler::EnforceBestChainLock()
253251
return;
254252
}
255253
LOCK(::cs_main);
256-
if (m_chainman.ActiveTip()->GetAncestor(currentBestChainLockBlockIndex->nHeight) !=
257-
currentBestChainLockBlockIndex) {
254+
if (m_chainman.ActiveTip()->GetAncestor(currentBestChainLockBlockIndex->nHeight) != currentBestChainLockBlockIndex) {
258255
return;
259256
}
260257
}
@@ -265,7 +262,8 @@ void ChainlockHandler::EnforceBestChainLock()
265262
lastNotifyChainLockBlockIndex = currentBestChainLockBlockIndex;
266263
}
267264

268-
GetMainSignals().NotifyChainLock(currentBestChainLockBlockIndex, std::make_shared<chainlock::ChainLockSig>(clsig), clsig.ToString());
265+
GetMainSignals().NotifyChainLock(currentBestChainLockBlockIndex, std::make_shared<chainlock::ChainLockSig>(clsig),
266+
clsig.ToString());
269267
uiInterface.NotifyChainLock(clsig.getBlockHash().ToString(), clsig.getHeight());
270268
::g_stats_client->gauge("chainlocks.blockHeight", clsig.getHeight(), 1.0f);
271269
}
@@ -325,12 +323,13 @@ void ChainlockHandler::Cleanup()
325323
}
326324
}
327325

328-
llmq::VerifyRecSigStatus VerifyChainLock(const Consensus::Params& params, const CChain& chain, const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig)
326+
llmq::VerifyRecSigStatus VerifyChainLock(const Consensus::Params& params, const CChain& chain,
327+
const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig)
329328
{
330329
const auto llmqType = params.llmqTypeChainLocks;
331330
const uint256 request_id = chainlock::GenSigRequestId(clsig.getHeight());
332331

333-
return llmq::VerifyRecoveredSig(llmqType, chain, qman, clsig.getHeight(), request_id,
334-
clsig.getBlockHash(), clsig.getSig());
332+
return llmq::VerifyRecoveredSig(llmqType, chain, qman, clsig.getHeight(), request_id, clsig.getBlockHash(),
333+
clsig.getSig());
335334
}
336335
} // namespace chainlock

src/chainlock/handler.h

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ namespace Consensus {
3535
struct Params;
3636
} // namespace Consensus
3737

38-
namespace llmq
39-
{
38+
namespace llmq {
4039
class CQuorumManager;
4140
enum class VerifyRecSigStatus : uint8_t;
4241
} // namespace llmq
@@ -71,49 +70,46 @@ class ChainlockHandler final : public CValidationInterface
7170
ChainlockHandler() = delete;
7271
ChainlockHandler(const ChainlockHandler&) = delete;
7372
ChainlockHandler& operator=(const ChainlockHandler&) = delete;
74-
explicit ChainlockHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
75-
CTxMemPool& _mempool, const CMasternodeSync& mn_sync);
73+
explicit ChainlockHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman, CTxMemPool& _mempool,
74+
const CMasternodeSync& mn_sync);
7675
~ChainlockHandler();
7776

7877
void Start();
7978
void Stop();
8079

81-
bool AlreadyHave(const CInv& inv) const
82-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
80+
bool AlreadyHave(const CInv& inv) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
8381
void UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time) EXCLUSIVE_LOCKS_REQUIRED(!cs);
8482

85-
[[nodiscard]] MessageProcessingResult ProcessNewChainLock(NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
83+
[[nodiscard]] MessageProcessingResult ProcessNewChainLock(NodeId from, const chainlock::ChainLockSig& clsig,
84+
const llmq::CQuorumManager& qman,
8685

87-
const uint256& hash)
88-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
86+
const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(!cs);
8987

9088
public:
91-
void CheckActiveState()
92-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
93-
void EnforceBestChainLock()
94-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
89+
void CheckActiveState() EXCLUSIVE_LOCKS_REQUIRED(!cs);
90+
void EnforceBestChainLock() EXCLUSIVE_LOCKS_REQUIRED(!cs);
9591

96-
bool IsTxSafeForMining(const uint256& txid) const
97-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
92+
bool IsTxSafeForMining(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
9893

99-
void CleanupFromSigner(const std::vector<std::shared_ptr<Uint256HashSet>>& cleanup_txes)
100-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
94+
void CleanupFromSigner(const std::vector<std::shared_ptr<Uint256HashSet>>& cleanup_txes) EXCLUSIVE_LOCKS_REQUIRED(!cs);
10195

10296
protected:
10397
// CValidationInterface
104-
void AcceptedBlockHeader(const CBlockIndex *pindexNew) override EXCLUSIVE_LOCKS_REQUIRED(!cs);
105-
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override EXCLUSIVE_LOCKS_REQUIRED(!cs);
106-
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t mempool_sequence) override EXCLUSIVE_LOCKS_REQUIRED(!cs);
98+
void AcceptedBlockHeader(const CBlockIndex* pindexNew) override EXCLUSIVE_LOCKS_REQUIRED(!cs);
99+
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override
100+
EXCLUSIVE_LOCKS_REQUIRED(!cs);
101+
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t mempool_sequence) override
102+
EXCLUSIVE_LOCKS_REQUIRED(!cs);
107103

108104
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex) override
109105
EXCLUSIVE_LOCKS_REQUIRED(!cs);
110106

111107
private:
112-
void Cleanup()
113-
EXCLUSIVE_LOCKS_REQUIRED(!cs);
108+
void Cleanup() EXCLUSIVE_LOCKS_REQUIRED(!cs);
114109
};
115110

116-
llmq::VerifyRecSigStatus VerifyChainLock(const Consensus::Params& params, const CChain& chain, const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig);
111+
llmq::VerifyRecSigStatus VerifyChainLock(const Consensus::Params& params, const CChain& chain,
112+
const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig);
117113
} // namespace chainlock
118114

119115
#endif // BITCOIN_CHAINLOCK_HANDLER_H

0 commit comments

Comments
 (0)