refactor: prefix member variable names with m_

This commit is contained in:
Kittywhiskers Van Gogh 2024-03-12 03:57:06 +00:00
parent 73cef4f5f9
commit 44beb941cb
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 33 additions and 33 deletions

View File

@ -18,10 +18,10 @@
// Keep track of the active Masternode // Keep track of the active Masternode
std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager; std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager;
CActiveMasternodeManager::CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& _connman, const std::unique_ptr<CDeterministicMNManager>& dmnman) : CActiveMasternodeManager::CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& connman, const std::unique_ptr<CDeterministicMNManager>& dmnman) :
m_info(sk, sk.GetPublicKey()), m_info(sk, sk.GetPublicKey()),
connman(_connman), m_connman{connman},
m_dmnman(dmnman) m_dmnman{dmnman}
{ {
assert(sk.IsValid()); /* We can assume pk is valid if sk is valid */ assert(sk.IsValid()); /* We can assume pk is valid if sk is valid */
LogPrintf("MASTERNODE:\n blsPubKeyOperator legacy: %s\n blsPubKeyOperator basic: %s\n", LogPrintf("MASTERNODE:\n blsPubKeyOperator legacy: %s\n blsPubKeyOperator basic: %s\n",
@ -31,7 +31,7 @@ CActiveMasternodeManager::CActiveMasternodeManager(const CBLSSecretKey& sk, CCon
std::string CActiveMasternodeManager::GetStateString() const std::string CActiveMasternodeManager::GetStateString() const
{ {
switch (state) { switch (m_state) {
case MASTERNODE_WAITING_FOR_PROTX: case MASTERNODE_WAITING_FOR_PROTX:
return "WAITING_FOR_PROTX"; return "WAITING_FOR_PROTX";
case MASTERNODE_POSE_BANNED: case MASTERNODE_POSE_BANNED:
@ -53,7 +53,7 @@ std::string CActiveMasternodeManager::GetStateString() const
std::string CActiveMasternodeManager::GetStatus() const std::string CActiveMasternodeManager::GetStatus() const
{ {
switch (state) { switch (m_state) {
case MASTERNODE_WAITING_FOR_PROTX: case MASTERNODE_WAITING_FOR_PROTX:
return "Waiting for ProTx to appear on-chain"; return "Waiting for ProTx to appear on-chain";
case MASTERNODE_POSE_BANNED: case MASTERNODE_POSE_BANNED:
@ -67,7 +67,7 @@ std::string CActiveMasternodeManager::GetStatus() const
case MASTERNODE_READY: case MASTERNODE_READY:
return "Ready"; return "Ready";
case MASTERNODE_ERROR: case MASTERNODE_ERROR:
return "Error. " + strError; return "Error. " + m_error;
default: default:
return "Unknown"; return "Unknown";
} }
@ -84,14 +84,14 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
// Check that our local network configuration is correct // Check that our local network configuration is correct
if (!fListen && Params().RequireRoutableExternalIP()) { if (!fListen && Params().RequireRoutableExternalIP()) {
// listen option is probably overwritten by something else, no good // listen option is probably overwritten by something else, no good
state = MASTERNODE_ERROR; m_state = MASTERNODE_ERROR;
strError = "Masternode must accept connections from outside. Make sure listen configuration option is not overwritten by some another parameter."; m_error = "Masternode must accept connections from outside. Make sure listen configuration option is not overwritten by some another parameter.";
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", m_error);
return; return;
} }
if (!GetLocalAddress(m_info.service)) { if (!GetLocalAddress(m_info.service)) {
state = MASTERNODE_ERROR; m_state = MASTERNODE_ERROR;
return; return;
} }
@ -105,9 +105,9 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
if (!mnList.IsMNValid(dmn->proTxHash)) { if (!mnList.IsMNValid(dmn->proTxHash)) {
if (mnList.IsMNPoSeBanned(dmn->proTxHash)) { if (mnList.IsMNPoSeBanned(dmn->proTxHash)) {
state = MASTERNODE_POSE_BANNED; m_state = MASTERNODE_POSE_BANNED;
} else { } else {
state = MASTERNODE_REMOVED; m_state = MASTERNODE_REMOVED;
} }
return; return;
} }
@ -115,9 +115,9 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
LogPrintf("CActiveMasternodeManager::Init -- proTxHash=%s, proTx=%s\n", dmn->proTxHash.ToString(), dmn->ToString()); LogPrintf("CActiveMasternodeManager::Init -- proTxHash=%s, proTx=%s\n", dmn->proTxHash.ToString(), dmn->ToString());
if (m_info.service != dmn->pdmnState->addr) { if (m_info.service != dmn->pdmnState->addr) {
state = MASTERNODE_ERROR; m_state = MASTERNODE_ERROR;
strError = "Local address does not match the address from ProTx"; m_error = "Local address does not match the address from ProTx";
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", m_error);
return; return;
} }
@ -125,25 +125,25 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
LogPrintf("CActiveMasternodeManager::Init -- Checking inbound connection to '%s'\n", m_info.service.ToString()); LogPrintf("CActiveMasternodeManager::Init -- Checking inbound connection to '%s'\n", m_info.service.ToString());
std::unique_ptr<Sock> sock = CreateSock(m_info.service); std::unique_ptr<Sock> sock = CreateSock(m_info.service);
if (!sock) { if (!sock) {
state = MASTERNODE_ERROR; m_state = MASTERNODE_ERROR;
strError = "Could not create socket to connect to " + m_info.service.ToString(); m_error = "Could not create socket to connect to " + m_info.service.ToString();
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", m_error);
return; return;
} }
bool fConnected = ConnectSocketDirectly(m_info.service, *sock, nConnectTimeout, true) && IsSelectableSocket(sock->Get()); bool fConnected = ConnectSocketDirectly(m_info.service, *sock, nConnectTimeout, true) && IsSelectableSocket(sock->Get());
sock->Reset(); sock->Reset();
if (!fConnected && Params().RequireRoutableExternalIP()) { if (!fConnected && Params().RequireRoutableExternalIP()) {
state = MASTERNODE_ERROR; m_state = MASTERNODE_ERROR;
strError = "Could not connect to " + m_info.service.ToString(); m_error = "Could not connect to " + m_info.service.ToString();
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", m_error);
return; return;
} }
m_info.proTxHash = dmn->proTxHash; m_info.proTxHash = dmn->proTxHash;
m_info.outpoint = dmn->collateralOutpoint; m_info.outpoint = dmn->collateralOutpoint;
m_info.legacy = dmn->pdmnState->nVersion == CProRegTx::LEGACY_BLS_VERSION; m_info.legacy = dmn->pdmnState->nVersion == CProRegTx::LEGACY_BLS_VERSION;
state = MASTERNODE_READY; m_state = MASTERNODE_READY;
} }
void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
@ -154,12 +154,12 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
if (!DeploymentDIP0003Enforced(pindexNew->nHeight, Params().GetConsensus())) return; if (!DeploymentDIP0003Enforced(pindexNew->nHeight, Params().GetConsensus())) return;
if (state == MASTERNODE_READY) { if (m_state == MASTERNODE_READY) {
auto oldMNList = Assert(m_dmnman)->GetListForBlock(pindexNew->pprev); auto oldMNList = Assert(m_dmnman)->GetListForBlock(pindexNew->pprev);
auto newMNList = m_dmnman->GetListForBlock(pindexNew); auto newMNList = m_dmnman->GetListForBlock(pindexNew);
if (!newMNList.IsMNValid(m_info.proTxHash)) { if (!newMNList.IsMNValid(m_info.proTxHash)) {
// MN disappeared from MN list // MN disappeared from MN list
state = MASTERNODE_REMOVED; m_state = MASTERNODE_REMOVED;
m_info.proTxHash = uint256(); m_info.proTxHash = uint256();
m_info.outpoint.SetNull(); m_info.outpoint.SetNull();
// MN might have reappeared in same block with a new ProTx // MN might have reappeared in same block with a new ProTx
@ -171,7 +171,7 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
auto newDmn = newMNList.GetMN(m_info.proTxHash); auto newDmn = newMNList.GetMN(m_info.proTxHash);
if (newDmn->pdmnState->pubKeyOperator != oldDmn->pdmnState->pubKeyOperator) { if (newDmn->pdmnState->pubKeyOperator != oldDmn->pdmnState->pubKeyOperator) {
// MN operator key changed or revoked // MN operator key changed or revoked
state = MASTERNODE_OPERATOR_KEY_CHANGED; m_state = MASTERNODE_OPERATOR_KEY_CHANGED;
m_info.proTxHash = uint256(); m_info.proTxHash = uint256();
m_info.outpoint.SetNull(); m_info.outpoint.SetNull();
// MN might have reappeared in same block with a new ProTx // MN might have reappeared in same block with a new ProTx
@ -181,7 +181,7 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
if (newDmn->pdmnState->addr != oldDmn->pdmnState->addr) { if (newDmn->pdmnState->addr != oldDmn->pdmnState->addr) {
// MN IP changed // MN IP changed
state = MASTERNODE_PROTX_IP_CHANGED; m_state = MASTERNODE_PROTX_IP_CHANGED;
m_info.proTxHash = uint256(); m_info.proTxHash = uint256();
m_info.outpoint.SetNull(); m_info.outpoint.SetNull();
Init(pindexNew); Init(pindexNew);
@ -214,7 +214,7 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
bool empty = true; bool empty = true;
// If we have some peers, let's try to find our local address from one of them // If we have some peers, let's try to find our local address from one of them
auto service = WITH_LOCK(cs, return m_info.service); auto service = WITH_LOCK(cs, return m_info.service);
connman.ForEachNodeContinueIf(CConnman::AllNodes, [&](CNode* pnode) { m_connman.ForEachNodeContinueIf(CConnman::AllNodes, [&](CNode* pnode) {
empty = false; empty = false;
if (pnode->addr.IsIPv4()) if (pnode->addr.IsIPv4())
fFoundLocal = GetLocal(service, &pnode->addr) && IsValidNetAddr(service); fFoundLocal = GetLocal(service, &pnode->addr) && IsValidNetAddr(service);
@ -222,8 +222,8 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
}); });
// nothing and no live connections, can't do anything for now // nothing and no live connections, can't do anything for now
if (empty) { if (empty) {
strError = "Can't detect valid external address. Please consider using the externalip configuration option if problem persists. Make sure to use IPv4 address only."; m_error = "Can't detect valid external address. Please consider using the externalip configuration option if problem persists. Make sure to use IPv4 address only.";
LogPrintf("CActiveMasternodeManager::GetLocalAddress -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::GetLocalAddress -- ERROR: %s\n", m_error);
return false; return false;
} }
} }

View File

@ -44,15 +44,15 @@ public:
mutable RecursiveMutex cs; mutable RecursiveMutex cs;
private: private:
masternode_state_t state{MASTERNODE_WAITING_FOR_PROTX}; masternode_state_t m_state{MASTERNODE_WAITING_FOR_PROTX};
CActiveMasternodeInfo m_info GUARDED_BY(cs); CActiveMasternodeInfo m_info GUARDED_BY(cs);
std::string strError; std::string m_error;
CConnman& connman; CConnman& m_connman;
const std::unique_ptr<CDeterministicMNManager>& m_dmnman; const std::unique_ptr<CDeterministicMNManager>& m_dmnman;
public: public:
explicit CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& _connman, const std::unique_ptr<CDeterministicMNManager>& dmnman); explicit CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& connman, const std::unique_ptr<CDeterministicMNManager>& dmnman);
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override; void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override;