Skip to content

Commit

Permalink
Clang evo folder and activemasternode.* (#2418)
Browse files Browse the repository at this point in the history
* clang + manual formatting

* clang activemasternode.*

* bump copyright

* weirdness correction
  • Loading branch information
PastaPastaPasta authored and UdjinM6 committed Nov 6, 2018
1 parent 98bdf35 commit f0df5bf
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 212 deletions.
161 changes: 87 additions & 74 deletions src/activemasternode.cpp

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions src/activemasternode.h
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2017 The Dash Core developers
// Copyright (c) 2014-2018 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.

Expand All @@ -11,8 +11,8 @@
#include "primitives/transaction.h"
#include "validationinterface.h"

#include "evo/providertx.h"
#include "evo/deterministicmns.h"
#include "evo/providertx.h"

struct CActiveMasternodeInfo;
class CActiveLegacyMasternodeManager;
Expand Down Expand Up @@ -69,7 +69,7 @@ class CActiveDeterministicMasternodeManager : public CValidationInterface
std::string GetStatus() const;

private:
bool GetLocalAddress(CService &addrRet);
bool GetLocalAddress(CService& addrRet);
};

// Responsible for activating the Masternode and pinging the network (legacy MN list)
Expand Down Expand Up @@ -101,11 +101,12 @@ class CActiveLegacyMasternodeManager
std::string strNotCapableReason;


CActiveLegacyMasternodeManager()
: eType(MASTERNODE_UNKNOWN),
fPingerEnabled(false),
nState(ACTIVE_MASTERNODE_INITIAL)
{}
CActiveLegacyMasternodeManager() :
eType(MASTERNODE_UNKNOWN),
fPingerEnabled(false),
nState(ACTIVE_MASTERNODE_INITIAL)
{
}

/// Manage state of active Masternode
void ManageState(CConnman& connman);
Expand All @@ -116,7 +117,7 @@ class CActiveLegacyMasternodeManager

bool UpdateSentinelPing(int version);

void DoMaintenance(CConnman &connman);
void DoMaintenance(CConnman& connman);

private:
void ManageStateInitial(CConnman& connman);
Expand Down
6 changes: 3 additions & 3 deletions src/evo/cbtx.cpp
@@ -1,14 +1,14 @@
// Copyright (c) 2017 The Dash Core developers
// Copyright (c) 2017-2018 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "cbtx.h"
#include "specialtx.h"
#include "deterministicmns.h"
#include "simplifiedmns.h"
#include "specialtx.h"

#include "validation.h"
#include "univalue.h"
#include "validation.h"

bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state)
{
Expand Down
6 changes: 3 additions & 3 deletions src/evo/cbtx.h
@@ -1,12 +1,12 @@
// Copyright (c) 2017 The Dash Core developers
// Copyright (c) 2017-2018 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef DASH_CBTX_H
#define DASH_CBTX_H

#include "primitives/transaction.h"
#include "consensus/validation.h"
#include "primitives/transaction.h"

class CBlock;
class CBlockIndex;
Expand Down Expand Up @@ -43,4 +43,4 @@ bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidatio
bool CheckCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev, uint256& merkleRootRet, CValidationState& state);

#endif//DASH_CBTX_H
#endif //DASH_CBTX_H
52 changes: 26 additions & 26 deletions src/evo/deterministicmns.cpp
Expand Up @@ -5,13 +5,13 @@
#include "deterministicmns.h"
#include "specialtx.h"

#include "validation.h"
#include "validationinterface.h"
#include "chainparams.h"
#include "script/standard.h"
#include "base58.h"
#include "chainparams.h"
#include "core_io.h"
#include "script/standard.h"
#include "spork.h"
#include "validation.h"
#include "validationinterface.h"

#include <univalue.h>

Expand All @@ -33,9 +33,9 @@ std::string CDeterministicMNState::ToString() const
}

return strprintf("CDeterministicMNState(nRegisteredHeight=%d, nLastPaidHeight=%d, nPoSePenalty=%d, nPoSeRevivedHeight=%d, nPoSeBanHeight=%d, nRevocationReason=%d, "
"keyIDOwner=%s, pubKeyOperator=%s, keyIDVoting=%s, addr=%s, payoutAddress=%s, operatorRewardAddress=%s)",
nRegisteredHeight, nLastPaidHeight, nPoSePenalty, nPoSeRevivedHeight, nPoSeBanHeight, nRevocationReason,
keyIDOwner.ToString(), pubKeyOperator.ToString(), keyIDVoting.ToString(), addr.ToStringIPPort(false), payoutAddress, operatorRewardAddress);
"keyIDOwner=%s, pubKeyOperator=%s, keyIDVoting=%s, addr=%s, payoutAddress=%s, operatorRewardAddress=%s)",
nRegisteredHeight, nLastPaidHeight, nPoSePenalty, nPoSeRevivedHeight, nPoSeBanHeight, nRevocationReason,
keyIDOwner.ToString(), pubKeyOperator.ToString(), keyIDVoting.ToString(), addr.ToStringIPPort(false), payoutAddress, operatorRewardAddress);
}

void CDeterministicMNState::ToJson(UniValue& obj) const
Expand Down Expand Up @@ -147,18 +147,18 @@ CDeterministicMNCPtr CDeterministicMNList::GetMNByCollateral(const COutPoint& co
return GetUniquePropertyMN(collateralOutpoint);
}

static int CompareByLastPaid_GetHeight(const CDeterministicMN &dmn)
static int CompareByLastPaid_GetHeight(const CDeterministicMN& dmn)
{
int h = dmn.pdmnState->nLastPaidHeight;
if (dmn.pdmnState->nPoSeRevivedHeight != -1 && dmn.pdmnState->nPoSeRevivedHeight > h) {
h = dmn.pdmnState->nPoSeRevivedHeight;
} else if (h == 0) {
h = dmn.pdmnState->nRegisteredHeight;
int height = dmn.pdmnState->nLastPaidHeight;
if (dmn.pdmnState->nPoSeRevivedHeight != -1 && dmn.pdmnState->nPoSeRevivedHeight > height) {
height = dmn.pdmnState->nPoSeRevivedHeight;
} else if (height == 0) {
height = dmn.pdmnState->nRegisteredHeight;
}
return h;
return height;
}

static bool CompareByLastPaid(const CDeterministicMN &_a, const CDeterministicMN &_b)
static bool CompareByLastPaid(const CDeterministicMN& _a, const CDeterministicMN& _b)
{
int ah = CompareByLastPaid_GetHeight(_a);
int bh = CompareByLastPaid_GetHeight(_b);
Expand All @@ -168,7 +168,7 @@ static bool CompareByLastPaid(const CDeterministicMN &_a, const CDeterministicMN
return ah < bh;
}
}
static bool CompareByLastPaid(const CDeterministicMNCPtr &_a, const CDeterministicMNCPtr &_b)
static bool CompareByLastPaid(const CDeterministicMNCPtr& _a, const CDeterministicMNCPtr& _b)
{
return CompareByLastPaid(*_a, *_b);
}
Expand Down Expand Up @@ -256,7 +256,7 @@ CDeterministicMNList CDeterministicMNList::ApplyDiff(const CDeterministicMNListD
return result;
}

void CDeterministicMNList::AddMN(const CDeterministicMNCPtr &dmn)
void CDeterministicMNList::AddMN(const CDeterministicMNCPtr& dmn)
{
assert(!mnMap.find(dmn->proTxHash));
mnMap = mnMap.set(dmn->proTxHash, dmn);
Expand All @@ -266,7 +266,7 @@ void CDeterministicMNList::AddMN(const CDeterministicMNCPtr &dmn)
AddUniqueProperty(dmn, dmn->pdmnState->pubKeyOperator);
}

void CDeterministicMNList::UpdateMN(const uint256 &proTxHash, const CDeterministicMNStateCPtr &pdmnState)
void CDeterministicMNList::UpdateMN(const uint256& proTxHash, const CDeterministicMNStateCPtr& pdmnState)
{
auto oldDmn = mnMap.find(proTxHash);
assert(oldDmn != nullptr);
Expand Down Expand Up @@ -320,7 +320,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0) {
evoDb.Write(std::make_pair(DB_LIST_SNAPSHOT, diff.blockHash), newList);
LogPrintf("CDeterministicMNManager::%s -- Wrote snapshot. nHeight=%d, mapCurMNs.allMNsCount=%d\n",
__func__, nHeight, newList.GetAllMNsCount());
__func__, nHeight, newList.GetAllMNsCount());
}

if (nHeight == GetSpork15Value()) {
Expand Down Expand Up @@ -382,7 +382,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
newList.RemoveMN(dmn->proTxHash);

LogPrintf("CDeterministicMNManager::%s -- MN %s removed from list because collateral was spent. collateralOutpoint=%s, nHeight=%d, mapCurMNs.allMNsCount=%d\n",
__func__, dmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort(), nHeight, newList.GetAllMNsCount());
__func__, dmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort(), nHeight, newList.GetAllMNsCount());
}
}

Expand Down Expand Up @@ -432,7 +432,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
newList.AddMN(dmn);

LogPrintf("CDeterministicMNManager::%s -- MN %s added at height %d: %s\n",
__func__, tx.GetHash().ToString(), nHeight, proTx.ToString());
__func__, tx.GetHash().ToString(), nHeight, proTx.ToString());
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
CProUpServTx proTx;
if (!GetTxPayload(tx, proTx)) {
Expand All @@ -458,14 +458,14 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
newState->nPoSeRevivedHeight = nHeight;

LogPrintf("CDeterministicMNManager::%s -- MN %s revived at height %d\n",
__func__, proTx.proTxHash.ToString(), nHeight);
__func__, proTx.proTxHash.ToString(), nHeight);
}
}

newList.UpdateMN(proTx.proTxHash, newState);

LogPrintf("CDeterministicMNManager::%s -- MN %s updated at height %d: %s\n",
__func__, proTx.proTxHash.ToString(), nHeight, proTx.ToString());
__func__, proTx.proTxHash.ToString(), nHeight, proTx.ToString());
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
CProUpRegTx proTx;
if (!GetTxPayload(tx, proTx)) {
Expand All @@ -489,7 +489,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
newList.UpdateMN(proTx.proTxHash, newState);

LogPrintf("CDeterministicMNManager::%s -- MN %s updated at height %d: %s\n",
__func__, proTx.proTxHash.ToString(), nHeight, proTx.ToString());
__func__, proTx.proTxHash.ToString(), nHeight, proTx.ToString());
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
CProUpRevTx proTx;
if (!GetTxPayload(tx, proTx)) {
Expand All @@ -508,7 +508,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
newList.UpdateMN(proTx.proTxHash, newState);

LogPrintf("CDeterministicMNManager::%s -- MN %s revoked operator key at height %d: %s\n",
__func__, proTx.proTxHash.ToString(), nHeight, proTx.ToString());
__func__, proTx.proTxHash.ToString(), nHeight, proTx.ToString());
}
}

Expand Down Expand Up @@ -538,7 +538,7 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlock(const uint256& blo
CDeterministicMNList snapshot;
std::list<CDeterministicMNListDiff> listDiff;

while(true) {
while (true) {
// try using cache before reading from disk
it = mnListsCache.find(blockHashTmp);
if (it != mnListsCache.end()) {
Expand Down

0 comments on commit f0df5bf

Please sign in to comment.