From f0df5bffa63202655a80a55a2513344fb20e54e6 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta Date: Tue, 6 Nov 2018 02:54:23 -0600 Subject: [PATCH] Clang evo folder and activemasternode.* (#2418) * clang + manual formatting * clang activemasternode.* * bump copyright * weirdness correction --- src/activemasternode.cpp | 161 +++++++++++++++++++---------------- src/activemasternode.h | 19 +++-- src/evo/cbtx.cpp | 6 +- src/evo/cbtx.h | 6 +- src/evo/deterministicmns.cpp | 52 +++++------ src/evo/deterministicmns.h | 61 +++++++------ src/evo/evodb.cpp | 4 +- src/evo/evodb.h | 6 +- src/evo/providertx.cpp | 26 +++--- src/evo/providertx.h | 12 +-- src/evo/simplifiedmns.cpp | 14 +-- src/evo/simplifiedmns.h | 14 +-- src/evo/specialtx.cpp | 60 ++++++------- src/evo/specialtx.h | 4 +- 14 files changed, 233 insertions(+), 212 deletions(-) diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index f1eee8131236f..b13437a8d3e75 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2017 The Dash Core developers +// Copyright (c) 2014-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 "activemasternode.h" -#include "masternode.h" +#include "evo/deterministicmns.h" +#include "init.h" #include "masternode-sync.h" +#include "masternode.h" #include "masternodeman.h" #include "netbase.h" #include "protocol.h" -#include "netbase.h" #include "warnings.h" -#include "init.h" -#include "evo/deterministicmns.h" // Keep track of the active Masternode CActiveMasternodeInfo activeMasternodeInfo; @@ -21,24 +20,36 @@ CActiveDeterministicMasternodeManager* activeMasternodeManager; std::string CActiveDeterministicMasternodeManager::GetStateString() const { switch (state) { - case MASTERNODE_WAITING_FOR_PROTX: return "WAITING_FOR_PROTX"; - case MASTERNODE_POSE_BANNED: return "POSE_BANNED"; - case MASTERNODE_REMOVED: return "REMOVED"; - case MASTERNODE_READY: return "READY"; - case MASTERNODE_ERROR: return "ERROR"; - default: return "UNKNOWN"; + case MASTERNODE_WAITING_FOR_PROTX: + return "WAITING_FOR_PROTX"; + case MASTERNODE_POSE_BANNED: + return "POSE_BANNED"; + case MASTERNODE_REMOVED: + return "REMOVED"; + case MASTERNODE_READY: + return "READY"; + case MASTERNODE_ERROR: + return "ERROR"; + default: + return "UNKNOWN"; } } std::string CActiveDeterministicMasternodeManager::GetStatus() const { switch (state) { - case MASTERNODE_WAITING_FOR_PROTX: return "Waiting for ProTx to appear on-chain"; - case MASTERNODE_POSE_BANNED: return "Masternode was PoSe banned"; - case MASTERNODE_REMOVED: return "Masternode removed from list"; - case MASTERNODE_READY: return "Ready"; - case MASTERNODE_ERROR: return "Error. " + strError; - default: return "Unknown"; + case MASTERNODE_WAITING_FOR_PROTX: + return "Waiting for ProTx to appear on-chain"; + case MASTERNODE_POSE_BANNED: + return "Masternode was PoSe banned"; + case MASTERNODE_REMOVED: + return "Masternode removed from list"; + case MASTERNODE_READY: + return "Ready"; + case MASTERNODE_ERROR: + return "Error. " + strError; + default: + return "Unknown"; } } @@ -46,11 +57,9 @@ void CActiveDeterministicMasternodeManager::Init() { LOCK(cs_main); - if (!fMasternodeMode) - return; + if (!fMasternodeMode) return; - if (!deterministicMNManager->IsDeterministicMNsSporkActive()) - return; + if (!deterministicMNManager->IsDeterministicMNsSporkActive()) return; if (!GetLocalAddress(activeMasternodeInfo.service)) { state = MASTERNODE_ERROR; @@ -93,12 +102,9 @@ void CActiveDeterministicMasternodeManager::UpdatedBlockTip(const CBlockIndex* p { LOCK(cs_main); - if (!fMasternodeMode) - return; + if (!fMasternodeMode) return; - if (!deterministicMNManager->IsDeterministicMNsSporkActive(pindexNew->nHeight)) { - return; - } + if (!deterministicMNManager->IsDeterministicMNsSporkActive(pindexNew->nHeight)) return; if (state == MASTERNODE_WAITING_FOR_PROTX) { Init(); @@ -117,7 +123,7 @@ void CActiveDeterministicMasternodeManager::UpdatedBlockTip(const CBlockIndex* p } } -bool CActiveDeterministicMasternodeManager::GetLocalAddress(CService &addrRet) +bool CActiveDeterministicMasternodeManager::GetLocalAddress(CService& addrRet) { // First try to find whatever local address is specified by externalip option bool fFoundLocal = GetLocal(addrRet) && CMasternode::IsValidNetAddr(addrRet); @@ -126,7 +132,7 @@ bool CActiveDeterministicMasternodeManager::GetLocalAddress(CService &addrRet) fFoundLocal = true; } } - if(!fFoundLocal) { + if (!fFoundLocal) { strError = "Can't detect valid external address. Please consider using the externalip configuration option if problem persists. Make sure to use IPv4 address only."; LogPrintf("CActiveDeterministicMasternodeManager::GetLocalAddress -- ERROR: %s\n", strError); return false; @@ -138,31 +144,30 @@ bool CActiveDeterministicMasternodeManager::GetLocalAddress(CService &addrRet) void CActiveLegacyMasternodeManager::ManageState(CConnman& connman) { - if (deterministicMNManager->IsDeterministicMNsSporkActive()) - return; + if (deterministicMNManager->IsDeterministicMNsSporkActive()) return; LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageState -- Start\n"); - if(!fMasternodeMode) { + if (!fMasternodeMode) { LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageState -- Not a masternode, returning\n"); return; } - if(Params().NetworkIDString() != CBaseChainParams::REGTEST && !masternodeSync.IsBlockchainSynced()) { + if (Params().NetworkIDString() != CBaseChainParams::REGTEST && !masternodeSync.IsBlockchainSynced()) { nState = ACTIVE_MASTERNODE_SYNC_IN_PROCESS; LogPrintf("CActiveLegacyMasternodeManager::ManageState -- %s: %s\n", GetStateString(), GetStatus()); return; } - if(nState == ACTIVE_MASTERNODE_SYNC_IN_PROCESS) { + if (nState == ACTIVE_MASTERNODE_SYNC_IN_PROCESS) { nState = ACTIVE_MASTERNODE_INITIAL; } LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageState -- status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled); - if(eType == MASTERNODE_UNKNOWN) { + if (eType == MASTERNODE_UNKNOWN) { ManageStateInitial(connman); } - if(eType == MASTERNODE_REMOTE) { + if (eType == MASTERNODE_REMOTE) { ManageStateRemote(); } @@ -172,31 +177,43 @@ void CActiveLegacyMasternodeManager::ManageState(CConnman& connman) std::string CActiveLegacyMasternodeManager::GetStateString() const { switch (nState) { - case ACTIVE_MASTERNODE_INITIAL: return "INITIAL"; - case ACTIVE_MASTERNODE_SYNC_IN_PROCESS: return "SYNC_IN_PROCESS"; - case ACTIVE_MASTERNODE_INPUT_TOO_NEW: return "INPUT_TOO_NEW"; - case ACTIVE_MASTERNODE_NOT_CAPABLE: return "NOT_CAPABLE"; - case ACTIVE_MASTERNODE_STARTED: return "STARTED"; - default: return "UNKNOWN"; + case ACTIVE_MASTERNODE_INITIAL: + return "INITIAL"; + case ACTIVE_MASTERNODE_SYNC_IN_PROCESS: + return "SYNC_IN_PROCESS"; + case ACTIVE_MASTERNODE_INPUT_TOO_NEW: + return "INPUT_TOO_NEW"; + case ACTIVE_MASTERNODE_NOT_CAPABLE: + return "NOT_CAPABLE"; + case ACTIVE_MASTERNODE_STARTED: + return "STARTED"; + default: + return "UNKNOWN"; } } std::string CActiveLegacyMasternodeManager::GetStatus() const { switch (nState) { - case ACTIVE_MASTERNODE_INITIAL: return "Node just started, not yet activated"; - case ACTIVE_MASTERNODE_SYNC_IN_PROCESS: return "Sync in progress. Must wait until sync is complete to start Masternode"; - case ACTIVE_MASTERNODE_INPUT_TOO_NEW: return strprintf("Masternode input must have at least %d confirmations", Params().GetConsensus().nMasternodeMinimumConfirmations); - case ACTIVE_MASTERNODE_NOT_CAPABLE: return "Not capable masternode: " + strNotCapableReason; - case ACTIVE_MASTERNODE_STARTED: return "Masternode successfully started"; - default: return "Unknown"; + case ACTIVE_MASTERNODE_INITIAL: + return "Node just started, not yet activated"; + case ACTIVE_MASTERNODE_SYNC_IN_PROCESS: + return "Sync in progress. Must wait until sync is complete to start Masternode"; + case ACTIVE_MASTERNODE_INPUT_TOO_NEW: + return strprintf("Masternode input must have at least %d confirmations", Params().GetConsensus().nMasternodeMinimumConfirmations); + case ACTIVE_MASTERNODE_NOT_CAPABLE: + return "Not capable masternode: " + strNotCapableReason; + case ACTIVE_MASTERNODE_STARTED: + return "Masternode successfully started"; + default: + return "Unknown"; } } std::string CActiveLegacyMasternodeManager::GetTypeString() const { std::string strType; - switch(eType) { + switch (eType) { case MASTERNODE_REMOTE: strType = "REMOTE"; break; @@ -209,15 +226,14 @@ std::string CActiveLegacyMasternodeManager::GetTypeString() const bool CActiveLegacyMasternodeManager::SendMasternodePing(CConnman& connman) { - if (deterministicMNManager->IsDeterministicMNsSporkActive()) - return false; + if (deterministicMNManager->IsDeterministicMNsSporkActive()) return false; - if(!fPingerEnabled) { + if (!fPingerEnabled) { LogPrint("masternode", "CActiveLegacyMasternodeManager::SendMasternodePing -- %s: masternode ping service is disabled, skipping...\n", GetStateString()); return false; } - if(!mnodeman.Has(activeMasternodeInfo.outpoint)) { + if (!mnodeman.Has(activeMasternodeInfo.outpoint)) { strNotCapableReason = "Masternode not in masternode list"; nState = ACTIVE_MASTERNODE_NOT_CAPABLE; LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- %s: %s\n", GetStateString(), strNotCapableReason); @@ -227,14 +243,14 @@ bool CActiveLegacyMasternodeManager::SendMasternodePing(CConnman& connman) CMasternodePing mnp(activeMasternodeInfo.outpoint); mnp.nSentinelVersion = nSentinelVersion; mnp.fSentinelIsCurrent = - (abs(GetAdjustedTime() - nSentinelPingTime) < MASTERNODE_SENTINEL_PING_MAX_SECONDS); - if(!mnp.Sign(activeMasternodeInfo.legacyKeyOperator, activeMasternodeInfo.legacyKeyIDOperator)) { + (abs(GetAdjustedTime() - nSentinelPingTime) < MASTERNODE_SENTINEL_PING_MAX_SECONDS); + if (!mnp.Sign(activeMasternodeInfo.legacyKeyOperator, activeMasternodeInfo.legacyKeyIDOperator)) { LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- ERROR: Couldn't sign Masternode Ping\n"); return false; } // Update lastPing for our masternode in Masternode list - if(mnodeman.IsMasternodePingedWithin(activeMasternodeInfo.outpoint, MASTERNODE_MIN_MNP_SECONDS, mnp.sigTime)) { + if (mnodeman.IsMasternodePingedWithin(activeMasternodeInfo.outpoint, MASTERNODE_MIN_MNP_SECONDS, mnp.sigTime)) { LogPrintf("CActiveLegacyMasternodeManager::SendMasternodePing -- Too early to send Masternode Ping\n"); return false; } @@ -255,7 +271,7 @@ bool CActiveLegacyMasternodeManager::UpdateSentinelPing(int version) return true; } -void CActiveLegacyMasternodeManager::DoMaintenance(CConnman &connman) +void CActiveLegacyMasternodeManager::DoMaintenance(CConnman& connman) { if (ShutdownRequested()) return; @@ -264,8 +280,7 @@ void CActiveLegacyMasternodeManager::DoMaintenance(CConnman &connman) void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman) { - if (deterministicMNManager->IsDeterministicMNsSporkActive()) - return; + if (deterministicMNManager->IsDeterministicMNsSporkActive()) return; LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateInitial -- status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetTypeString(), fPingerEnabled); @@ -280,7 +295,7 @@ void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman) // First try to find whatever local address is specified by externalip option bool fFoundLocal = GetLocal(activeMasternodeInfo.service) && CMasternode::IsValidNetAddr(activeMasternodeInfo.service); - if(!fFoundLocal) { + if (!fFoundLocal) { bool empty = true; // If we have some peers, let's try to find our local address from one of them connman.ForEachNodeContinueIf(CConnman::AllNodes, [&fFoundLocal, &empty](CNode* pnode) { @@ -304,7 +319,7 @@ void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman) } } - if(!fFoundLocal) { + if (!fFoundLocal) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = "Can't detect valid external address. Please consider using the externalip configuration option if problem persists. Make sure to use IPv4 address only."; LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason); @@ -312,21 +327,21 @@ void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman) } int mainnetDefaultPort = Params(CBaseChainParams::MAIN).GetDefaultPort(); - if(Params().NetworkIDString() == CBaseChainParams::MAIN) { - if(activeMasternodeInfo.service.GetPort() != mainnetDefaultPort) { + if (Params().NetworkIDString() == CBaseChainParams::MAIN) { + if (activeMasternodeInfo.service.GetPort() != mainnetDefaultPort) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = strprintf("Invalid port: %u - only %d is supported on mainnet.", activeMasternodeInfo.service.GetPort(), mainnetDefaultPort); LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason); return; } - } else if(activeMasternodeInfo.service.GetPort() == mainnetDefaultPort) { + } else if (activeMasternodeInfo.service.GetPort() == mainnetDefaultPort) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = strprintf("Invalid port: %u - %d is only supported on mainnet.", activeMasternodeInfo.service.GetPort(), mainnetDefaultPort); LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason); return; } - if(Params().NetworkIDString() != CBaseChainParams::REGTEST) { + if (Params().NetworkIDString() != CBaseChainParams::REGTEST) { // Check socket connectivity LogPrintf("CActiveLegacyMasternodeManager::ManageStateInitial -- Checking inbound connection to '%s'\n", activeMasternodeInfo.service.ToString()); SOCKET hSocket; @@ -348,28 +363,27 @@ void CActiveLegacyMasternodeManager::ManageStateInitial(CConnman& connman) void CActiveLegacyMasternodeManager::ManageStateRemote() { - if (deterministicMNManager->IsDeterministicMNsSporkActive()) - return; + if (deterministicMNManager->IsDeterministicMNsSporkActive()) return; LogPrint("masternode", "CActiveLegacyMasternodeManager::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, keyIDOperator = %s\n", - GetStatus(), GetTypeString(), fPingerEnabled, activeMasternodeInfo.legacyKeyIDOperator.ToString()); + GetStatus(), GetTypeString(), fPingerEnabled, activeMasternodeInfo.legacyKeyIDOperator.ToString()); mnodeman.CheckMasternode(activeMasternodeInfo.legacyKeyIDOperator, true); masternode_info_t infoMn; - if(mnodeman.GetMasternodeInfo(activeMasternodeInfo.legacyKeyIDOperator, infoMn)) { - if(infoMn.nProtocolVersion != PROTOCOL_VERSION) { + if (mnodeman.GetMasternodeInfo(activeMasternodeInfo.legacyKeyIDOperator, infoMn)) { + if (infoMn.nProtocolVersion != PROTOCOL_VERSION) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = "Invalid protocol version"; LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason); return; } - if(activeMasternodeInfo.service != infoMn.addr) { + if (activeMasternodeInfo.service != infoMn.addr) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = "Broadcasted IP doesn't match our external address. Make sure you issued a new broadcast if IP of this masternode changed recently."; LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason); return; } - if(!CMasternode::IsValidStateForAutoStart(infoMn.nActiveState)) { + if (!CMasternode::IsValidStateForAutoStart(infoMn.nActiveState)) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = strprintf("Masternode in %s state", CMasternode::StateToString(infoMn.nActiveState)); LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason); @@ -385,15 +399,14 @@ void CActiveLegacyMasternodeManager::ManageStateRemote() } LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- Collateral is a ProTx\n"); } - if(nState != ACTIVE_MASTERNODE_STARTED) { + if (nState != ACTIVE_MASTERNODE_STARTED) { LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- STARTED!\n"); activeMasternodeInfo.outpoint = infoMn.outpoint; activeMasternodeInfo.service = infoMn.addr; fPingerEnabled = true; nState = ACTIVE_MASTERNODE_STARTED; } - } - else { + } else { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = "Masternode not in masternode list"; LogPrintf("CActiveLegacyMasternodeManager::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason); diff --git a/src/activemasternode.h b/src/activemasternode.h index cbe805b9a4887..7b3ef45009f05 100644 --- a/src/activemasternode.h +++ b/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. @@ -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; @@ -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) @@ -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); @@ -116,7 +117,7 @@ class CActiveLegacyMasternodeManager bool UpdateSentinelPing(int version); - void DoMaintenance(CConnman &connman); + void DoMaintenance(CConnman& connman); private: void ManageStateInitial(CConnman& connman); diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index cf48c69fa0785..9d0d5cd904a49 100644 --- a/src/evo/cbtx.cpp +++ b/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) { diff --git a/src/evo/cbtx.h b/src/evo/cbtx.h index 0cc508bfa323f..c9b1c0e1eb026 100644 --- a/src/evo/cbtx.h +++ b/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; @@ -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 diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index ff01d3f74a522..91bd0f228ee81 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -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 @@ -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 @@ -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); @@ -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); } @@ -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); @@ -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); @@ -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()) { @@ -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()); } } @@ -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)) { @@ -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)) { @@ -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)) { @@ -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()); } } @@ -538,7 +538,7 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlock(const uint256& blo CDeterministicMNList snapshot; std::list listDiff; - while(true) { + while (true) { // try using cache before reading from disk it = mnListsCache.find(blockHashTmp); if (it != mnListsCache.end()) { diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 09ba21d32296d..719a1dad178b9 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -5,11 +5,11 @@ #ifndef DASH_DETERMINISTICMNS_H #define DASH_DETERMINISTICMNS_H +#include "bls/bls.h" +#include "dbwrapper.h" #include "evodb.h" #include "providertx.h" -#include "dbwrapper.h" #include "sync.h" -#include "bls/bls.h" #include "immer/map.hpp" #include "immer/map_transient.hpp" @@ -47,8 +47,11 @@ class CDeterministicMNState addr = proTx.addr; scriptPayout = proTx.scriptPayout; } - template - CDeterministicMNState(deserialize_type, Stream& s) { s >> *this;} + template + CDeterministicMNState(deserialize_type, Stream& s) + { + s >> *this; + } ADD_SERIALIZE_METHODS; @@ -115,8 +118,11 @@ class CDeterministicMN { public: CDeterministicMN() {} - template - CDeterministicMN(deserialize_type, Stream& s) { s >> *this;} + template + CDeterministicMN(deserialize_type, Stream& s) + { + s >> *this; + } uint256 proTxHash; COutPoint collateralOutpoint; @@ -144,7 +150,7 @@ typedef std::shared_ptr CDeterministicMNCPtr; class CDeterministicMNListDiff; -template +template void SerializeImmerMap(Stream& os, const immer::map& m) { WriteCompactSize(os, m.size()); @@ -152,13 +158,12 @@ void SerializeImmerMap(Stream& os, const immer::map& m) Serialize(os, (*mi)); } -template +template void UnserializeImmerMap(Stream& is, immer::map& m) { m = immer::map(); unsigned int nSize = ReadCompactSize(is); - for (unsigned int i = 0; i < nSize; i++) - { + for (unsigned int i = 0; i < nSize; i++) { std::pair item; Unserialize(is, item); m = m.set(item.first, item.second); @@ -169,7 +174,7 @@ class CDeterministicMNList { public: typedef immer::map MnMap; - typedef immer::map> MnUniquePropertyMap; + typedef immer::map > MnUniquePropertyMap; private: uint256 blockHash; @@ -184,9 +189,10 @@ class CDeterministicMNList public: CDeterministicMNList() {} explicit CDeterministicMNList(const uint256& _blockHash, int _height) : - blockHash(_blockHash), - nHeight(_height) - {} + blockHash(_blockHash), + nHeight(_height) + { + } ADD_SERIALIZE_METHODS; @@ -205,7 +211,6 @@ class CDeterministicMNList } public: - size_t GetAllMNsCount() const { return mnMap.size(); @@ -222,8 +227,9 @@ class CDeterministicMNList return count; } - template - void ForEachMN(bool onlyValid, Callback&& cb) const { + template + void ForEachMN(bool onlyValid, Callback&& cb) const + { for (const auto& p : mnMap) { if (!onlyValid || IsMNValid(p.second)) { cb(p.second); @@ -254,7 +260,8 @@ class CDeterministicMNList bool IsMNValid(const CDeterministicMNCPtr& dmn) const; bool IsMNPoSeBanned(const CDeterministicMNCPtr& dmn) const; - bool HasMN(const uint256& proTxHash) const { + bool HasMN(const uint256& proTxHash) const + { return GetMN(proTxHash) != nullptr; } CDeterministicMNCPtr GetMN(const uint256& proTxHash) const; @@ -274,16 +281,16 @@ class CDeterministicMNList CDeterministicMNListDiff BuildDiff(const CDeterministicMNList& to) const; CDeterministicMNList ApplyDiff(const CDeterministicMNListDiff& diff) const; - void AddMN(const CDeterministicMNCPtr &dmn); - void UpdateMN(const uint256 &proTxHash, const CDeterministicMNStateCPtr &pdmnState); + void AddMN(const CDeterministicMNCPtr& dmn); + void UpdateMN(const uint256& proTxHash, const CDeterministicMNStateCPtr& pdmnState); void RemoveMN(const uint256& proTxHash); - template + template bool HasUniqueProperty(const T& v) const { return mnUniquePropertyMap.count(::SerializeHash(v)) != 0; } - template + template CDeterministicMNCPtr GetUniquePropertyMN(const T& v) const { auto p = mnUniquePropertyMap.find(::SerializeHash(v)); @@ -294,7 +301,7 @@ class CDeterministicMNList } private: - template + template void AddUniqueProperty(const CDeterministicMNCPtr& dmn, const T& v) { auto hash = ::SerializeHash(v); @@ -306,7 +313,7 @@ class CDeterministicMNList } mnUniquePropertyMap = mnUniquePropertyMap.set(hash, newEntry); } - template + template void DeleteUniqueProperty(const CDeterministicMNCPtr& dmn, const T& oldValue) { auto oldHash = ::SerializeHash(oldValue); @@ -318,7 +325,7 @@ class CDeterministicMNList mnUniquePropertyMap = mnUniquePropertyMap.set(oldHash, std::make_pair(dmn->proTxHash, p->second - 1)); } } - template + template void UpdateUniqueProperty(const CDeterministicMNCPtr& dmn, const T& oldValue, const T& newValue) { if (oldValue == newValue) { @@ -381,7 +388,7 @@ class CDeterministicMNManager bool ProcessBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& state); bool UndoBlock(const CBlock& block, const CBlockIndex* pindex); - void UpdatedBlockTip(const CBlockIndex *pindex); + void UpdatedBlockTip(const CBlockIndex* pindex); // the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet) bool BuildNewListFromBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& state, CDeterministicMNList& mnListRet); @@ -405,4 +412,4 @@ class CDeterministicMNManager extern CDeterministicMNManager* deterministicMNManager; -#endif//DASH_DETERMINISTICMNS_H +#endif //DASH_DETERMINISTICMNS_H diff --git a/src/evo/evodb.cpp b/src/evo/evodb.cpp index 5b91c3d2b3f4e..755579f2753ff 100644 --- a/src/evo/evodb.cpp +++ b/src/evo/evodb.cpp @@ -7,7 +7,7 @@ CEvoDB* evoDb; CEvoDB::CEvoDB(size_t nCacheSize, bool fMemory, bool fWipe) : - db(fMemory ? "" : (GetDataDir() / "evodb"), nCacheSize, fMemory, fWipe), - dbTransaction(db) + db(fMemory ? "" : (GetDataDir() / "evodb"), nCacheSize, fMemory, fWipe), + dbTransaction(db) { } diff --git a/src/evo/evodb.h b/src/evo/evodb.h index a830513e50785..0bdcc5a27eb4b 100644 --- a/src/evo/evodb.h +++ b/src/evo/evodb.h @@ -25,14 +25,14 @@ class CEvoDB return t; } - template + template bool Read(const K& key, V& value) { LOCK(cs); return dbTransaction.Read(key, value); } - template + template void Write(const K& key, const V& value) { LOCK(cs); @@ -61,4 +61,4 @@ class CEvoDB extern CEvoDB* evoDb; -#endif//DASH_EVODB_H +#endif //DASH_EVODB_H diff --git a/src/evo/providertx.cpp b/src/evo/providertx.cpp index b0f1b0e5f9d88..abf3afce96569 100644 --- a/src/evo/providertx.cpp +++ b/src/evo/providertx.cpp @@ -2,20 +2,20 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "deterministicmns.h" #include "providertx.h" #include "specialtx.h" -#include "deterministicmns.h" -#include "hash.h" -#include "clientversion.h" -#include "streams.h" -#include "messagesigner.h" +#include "base58.h" #include "chainparams.h" -#include "validation.h" -#include "univalue.h" +#include "clientversion.h" #include "core_io.h" +#include "hash.h" +#include "messagesigner.h" #include "script/standard.h" -#include "base58.h" +#include "streams.h" +#include "univalue.h" +#include "validation.h" template static bool CheckService(const uint256& proTxHash, const ProTx& proTx, const CBlockIndex* pindexPrev, CValidationState& state) @@ -55,7 +55,7 @@ template static bool CheckStringSig(const ProTx& proTx, const CKeyID& keyID, CValidationState& state) { std::string strError; - if (!CMessageSigner::VerifyMessage(keyID, proTx.vchSig, proTx.MakeSignString(), strError)) { + if (!CMessageSigner::VerifyMessage(keyID, proTx.vchSig, proTx.MakeSignString(), strError)) { return state.DoS(100, false, REJECT_INVALID, "bad-protx-sig", false, strError); } return true; @@ -71,7 +71,7 @@ static bool CheckHashSig(const ProTx& proTx, const CBLSPublicKey& pubKey, CValid } template -static bool CheckInputsHash(const CTransaction &tx, const ProTx& proTx, CValidationState& state) +static bool CheckInputsHash(const CTransaction& tx, const ProTx& proTx, CValidationState& state) { uint256 inputsHash = CalcTxInputsHash(tx); if (inputsHash != proTx.inputsHash) { @@ -427,7 +427,7 @@ std::string CProUpServTx::ToString() const } return strprintf("CProUpServTx(nVersion=%d, proTxHash=%s, addr=%s, operatorPayoutAddress=%s)", - nVersion, proTxHash.ToString(), addr.ToString(), payee); + nVersion, proTxHash.ToString(), addr.ToString(), payee); } void CProUpServTx::ToJson(UniValue& obj) const @@ -454,7 +454,7 @@ std::string CProUpRegTx::ToString() const } return strprintf("CProUpRegTx(nVersion=%d, proTxHash=%s, pubKeyOperator=%s, keyIDVoting=%s, payoutAddress=%s)", - nVersion, proTxHash.ToString(), pubKeyOperator.ToString(), keyIDVoting.ToString(), payee); + nVersion, proTxHash.ToString(), pubKeyOperator.ToString(), keyIDVoting.ToString(), payee); } void CProUpRegTx::ToJson(UniValue& obj) const @@ -476,7 +476,7 @@ void CProUpRegTx::ToJson(UniValue& obj) const std::string CProUpRevTx::ToString() const { return strprintf("CProUpRevTx(nVersion=%d, proTxHash=%s, nReason=%d)", - nVersion, proTxHash.ToString(), nReason); + nVersion, proTxHash.ToString(), nReason); } void CProUpRevTx::ToJson(UniValue& obj) const diff --git a/src/evo/providertx.h b/src/evo/providertx.h index e105f2c9547bc..bb5c0f18ebc0a 100644 --- a/src/evo/providertx.h +++ b/src/evo/providertx.h @@ -5,9 +5,9 @@ #ifndef DASH_PROVIDERTX_H #define DASH_PROVIDERTX_H -#include "primitives/transaction.h" -#include "consensus/validation.h" #include "bls/bls.h" +#include "consensus/validation.h" +#include "primitives/transaction.h" #include "netaddress.h" #include "pubkey.h" @@ -21,9 +21,9 @@ class CProRegTx static const uint16_t CURRENT_VERSION = 1; public: - uint16_t nVersion{CURRENT_VERSION}; // message version - uint16_t nType{0}; // only 0 supported for now - uint16_t nMode{0}; // only 0 supported for now + uint16_t nVersion{CURRENT_VERSION}; // message version + uint16_t nType{0}; // only 0 supported for now + uint16_t nMode{0}; // only 0 supported for now COutPoint collateralOutpoint{uint256(), (uint32_t)-1}; // if hash is null, we refer to a ProRegTx output CService addr; CKeyID keyIDOwner; @@ -183,4 +183,4 @@ bool CheckProUpServTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CVa bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state); bool CheckProUpRevTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state); -#endif//DASH_PROVIDERTX_H +#endif //DASH_PROVIDERTX_H diff --git a/src/evo/simplifiedmns.cpp b/src/evo/simplifiedmns.cpp index febdefef58329..16e7b49f63e9f 100644 --- a/src/evo/simplifiedmns.cpp +++ b/src/evo/simplifiedmns.cpp @@ -1,17 +1,17 @@ -// 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 "core_io.h" +#include "deterministicmns.h" #include "simplifiedmns.h" #include "specialtx.h" -#include "deterministicmns.h" -#include "cbtx.h" -#include "validation.h" -#include "univalue.h" -#include "consensus/merkle.h" #include "chainparams.h" +#include "consensus/merkle.h" +#include "univalue.h" +#include "validation.h" CSimplifiedMNListEntry::CSimplifiedMNListEntry(const CDeterministicMN& dmn) : proRegTxHash(dmn.proTxHash), @@ -68,7 +68,7 @@ CSimplifiedMNList::CSimplifiedMNList(const CDeterministicMNList& dmnList) }); } -uint256 CSimplifiedMNList::CalcMerkleRoot(bool *pmutated) const +uint256 CSimplifiedMNList::CalcMerkleRoot(bool* pmutated) const { std::vector leaves; leaves.reserve(mnList.size()); diff --git a/src/evo/simplifiedmns.h b/src/evo/simplifiedmns.h index 31abaeec001a2..0a95a344f07b6 100644 --- a/src/evo/simplifiedmns.h +++ b/src/evo/simplifiedmns.h @@ -1,15 +1,15 @@ -// 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_SIMPLIFIEDMNS_H #define DASH_SIMPLIFIEDMNS_H -#include "serialize.h" -#include "pubkey.h" -#include "netaddress.h" -#include "merkleblock.h" #include "bls/bls.h" +#include "merkleblock.h" +#include "netaddress.h" +#include "pubkey.h" +#include "serialize.h" class UniValue; class CDeterministicMNList; @@ -58,7 +58,7 @@ class CSimplifiedMNList CSimplifiedMNList(const std::vector& smlEntries); CSimplifiedMNList(const CDeterministicMNList& dmnList); - uint256 CalcMerkleRoot(bool *pmutated = NULL) const; + uint256 CalcMerkleRoot(bool* pmutated = NULL) const; }; /// P2P messages @@ -110,4 +110,4 @@ class CSimplifiedMNListDiff bool BuildSimplifiedMNListDiff(const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet); -#endif//DASH_SIMPLIFIEDMNS_H +#endif //DASH_SIMPLIFIEDMNS_H diff --git a/src/evo/specialtx.cpp b/src/evo/specialtx.cpp index 149a51908bdaf..f73e72c616274 100644 --- a/src/evo/specialtx.cpp +++ b/src/evo/specialtx.cpp @@ -2,17 +2,17 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "primitives/transaction.h" -#include "primitives/block.h" +#include "chainparams.h" +#include "clientversion.h" #include "consensus/validation.h" #include "hash.h" -#include "clientversion.h" +#include "primitives/block.h" +#include "primitives/transaction.h" #include "validation.h" -#include "chainparams.h" -#include "specialtx.h" -#include "deterministicmns.h" #include "cbtx.h" +#include "deterministicmns.h" +#include "specialtx.h" bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state) { @@ -26,16 +26,16 @@ bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CVali } switch (tx.nType) { - case TRANSACTION_PROVIDER_REGISTER: - return CheckProRegTx(tx, pindexPrev, state); - case TRANSACTION_PROVIDER_UPDATE_SERVICE: - return CheckProUpServTx(tx, pindexPrev, state); - case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: - return CheckProUpRegTx(tx, pindexPrev, state); - case TRANSACTION_PROVIDER_UPDATE_REVOKE: - return CheckProUpRevTx(tx, pindexPrev, state); - case TRANSACTION_COINBASE: - return CheckCbTx(tx, pindexPrev, state); + case TRANSACTION_PROVIDER_REGISTER: + return CheckProRegTx(tx, pindexPrev, state); + case TRANSACTION_PROVIDER_UPDATE_SERVICE: + return CheckProUpServTx(tx, pindexPrev, state); + case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: + return CheckProUpRegTx(tx, pindexPrev, state); + case TRANSACTION_PROVIDER_UPDATE_REVOKE: + return CheckProUpRevTx(tx, pindexPrev, state); + case TRANSACTION_COINBASE: + return CheckCbTx(tx, pindexPrev, state); } return state.DoS(10, false, REJECT_INVALID, "bad-tx-type"); @@ -48,13 +48,13 @@ bool ProcessSpecialTx(const CTransaction& tx, const CBlockIndex* pindex, CValida } switch (tx.nType) { - case TRANSACTION_PROVIDER_REGISTER: - case TRANSACTION_PROVIDER_UPDATE_SERVICE: - case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: - case TRANSACTION_PROVIDER_UPDATE_REVOKE: - return true; // handled in batches per block - case TRANSACTION_COINBASE: - return true; // nothing to do + case TRANSACTION_PROVIDER_REGISTER: + case TRANSACTION_PROVIDER_UPDATE_SERVICE: + case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: + case TRANSACTION_PROVIDER_UPDATE_REVOKE: + return true; // handled in batches per block + case TRANSACTION_COINBASE: + return true; // nothing to do } return state.DoS(100, false, REJECT_INVALID, "bad-tx-type"); @@ -67,13 +67,13 @@ bool UndoSpecialTx(const CTransaction& tx, const CBlockIndex* pindex) } switch (tx.nType) { - case TRANSACTION_PROVIDER_REGISTER: - case TRANSACTION_PROVIDER_UPDATE_SERVICE: - case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: - case TRANSACTION_PROVIDER_UPDATE_REVOKE: - return true; // handled in batches per block - case TRANSACTION_COINBASE: - return true; // nothing to do + case TRANSACTION_PROVIDER_REGISTER: + case TRANSACTION_PROVIDER_UPDATE_SERVICE: + case TRANSACTION_PROVIDER_UPDATE_REGISTRAR: + case TRANSACTION_PROVIDER_UPDATE_REVOKE: + return true; // handled in batches per block + case TRANSACTION_COINBASE: + return true; // nothing to do } return false; diff --git a/src/evo/specialtx.h b/src/evo/specialtx.h index 2d900da534c75..9eb49ea020177 100644 --- a/src/evo/specialtx.h +++ b/src/evo/specialtx.h @@ -5,9 +5,9 @@ #ifndef DASH_SPECIALTX_H #define DASH_SPECIALTX_H +#include "primitives/transaction.h" #include "streams.h" #include "version.h" -#include "primitives/transaction.h" class CBlock; class CBlockIndex; @@ -49,4 +49,4 @@ void SetTxPayload(CMutableTransaction& tx, const T& payload) uint256 CalcTxInputsHash(const CTransaction& tx); -#endif//DASH_SPECIALTX_H +#endif //DASH_SPECIALTX_H