forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.h
More file actions
127 lines (103 loc) · 3.92 KB
/
debug.h
File metadata and controls
127 lines (103 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright (c) 2018-2025 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_LLMQ_DEBUG_H
#define BITCOIN_LLMQ_DEBUG_H
#include <consensus/params.h>
#include <sync.h>
#include <univalue.h>
#include <functional>
#include <unordered_set>
class CDataStream;
class CDeterministicMNManager;
class ChainstateManager;
class CInv;
class CScheduler;
struct RPCResult;
namespace llmq
{
class CQuorumSnapshotManager;
enum class QuorumPhase;
class CDKGDebugMemberStatus
{
public:
union {
struct
{
// is it locally considered as bad (and thus removed from the validMembers set)
bool bad : 1;
// did we complain about this member
bool weComplain : 1;
// received message for DKG phases
bool receivedContribution : 1;
bool receivedComplaint : 1;
bool receivedJustification : 1;
bool receivedPrematureCommitment : 1;
} statusBits;
uint8_t statusBitset;
};
std::unordered_set<uint16_t> complaintsFromMembers;
public:
CDKGDebugMemberStatus() : statusBitset(0) {}
};
class CDKGDebugSessionStatus
{
public:
Consensus::LLMQType llmqType{Consensus::LLMQType::LLMQ_NONE};
uint256 quorumHash;
uint32_t quorumHeight{0};
QuorumPhase phase{0};
union {
struct
{
// sent messages for DKG phases
bool sentContributions : 1;
bool sentComplaint : 1;
bool sentJustification : 1;
bool sentPrematureCommitment : 1;
bool aborted : 1;
} statusBits;
uint8_t statusBitset;
};
std::vector<CDKGDebugMemberStatus> members;
public:
CDKGDebugSessionStatus() : statusBitset(0) {}
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional);
[[nodiscard]] UniValue ToJson(CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
const ChainstateManager& chainman, int quorumIndex, int detailLevel) const;
};
struct CDKGDebugStatus {
int64_t nTime{0};
std::map<std::pair<Consensus::LLMQType, int>, CDKGDebugSessionStatus> sessions;
};
class CDKGDebugManager
{
private:
CDeterministicMNManager& m_dmnman;
CQuorumSnapshotManager& m_qsnapman;
const ChainstateManager& m_chainman;
private:
mutable Mutex cs_lockStatus;
CDKGDebugStatus localStatus GUARDED_BY(cs_lockStatus);
public:
CDKGDebugManager(const CDKGDebugManager&) = delete;
CDKGDebugManager& operator=(const CDKGDebugManager&) = delete;
CDKGDebugManager(CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, const ChainstateManager& chainman);
~CDKGDebugManager();
void ResetLocalSessionStatus(Consensus::LLMQType llmqType, int quorumIndex) EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
void InitLocalSessionStatus(const Consensus::LLMQParams& llmqParams, int quorumIndex, const uint256& quorumHash,
int quorumHeight) EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
void UpdateLocalSessionStatus(Consensus::LLMQType llmqType, int quorumIndex,
std::function<bool(CDKGDebugSessionStatus& status)>&& func)
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
void UpdateLocalMemberStatus(Consensus::LLMQType llmqType, int quorumIndex, size_t memberIdx,
std::function<bool(CDKGDebugMemberStatus& status)>&& func)
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
size_t GetSessionCount() const
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional, bool inner_optional = false);
[[nodiscard]] UniValue ToJson(int detailLevel) const
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
};
} // namespace llmq
#endif // BITCOIN_LLMQ_DEBUG_H