From cc3b63d69e05d7e5df54a0db237af0789d35002e Mon Sep 17 00:00:00 2001 From: pasta Date: Sun, 11 Aug 2024 15:28:29 +0700 Subject: [PATCH 1/2] refactor: initialize variables in the header instead --- src/governance/object.cpp | 30 ++---------------------------- src/governance/object.h | 18 +++++++++--------- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/governance/object.cpp b/src/governance/object.cpp index c176b2196be19..64cef52018bc0 100644 --- a/src/governance/object.cpp +++ b/src/governance/object.cpp @@ -22,21 +22,7 @@ #include -CGovernanceObject::CGovernanceObject() : - cs(), - m_obj{}, - nDeletionTime(0), - fCachedLocalValidity(false), - strLocalValidityError(), - fCachedFunding(false), - fCachedValid(true), - fCachedDelete(false), - fCachedEndorsed(false), - fDirtyCache(true), - fExpired(false), - fUnparsable(false), - mapCurrentMNVotes(), - fileVotes() +CGovernanceObject::CGovernanceObject() { // PARSE JSON DATA STORAGE (VCHDATA) LoadData(); @@ -44,19 +30,7 @@ CGovernanceObject::CGovernanceObject() : CGovernanceObject::CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTimeIn, const uint256& nCollateralHashIn, const std::string& strDataHexIn) : cs(), - m_obj{nHashParentIn, nRevisionIn, nTimeIn, nCollateralHashIn, strDataHexIn}, - nDeletionTime(0), - fCachedLocalValidity(false), - strLocalValidityError(), - fCachedFunding(false), - fCachedValid(true), - fCachedDelete(false), - fCachedEndorsed(false), - fDirtyCache(true), - fExpired(false), - fUnparsable(false), - mapCurrentMNVotes(), - fileVotes() + m_obj{nHashParentIn, nRevisionIn, nTimeIn, nCollateralHashIn, strDataHexIn} { // PARSE JSON DATA STORAGE (VCHDATA) LoadData(); diff --git a/src/governance/object.h b/src/governance/object.h index 6cfea6eb502da..826823a33bedc 100644 --- a/src/governance/object.h +++ b/src/governance/object.h @@ -103,37 +103,37 @@ class CGovernanceObject Governance::Object m_obj; /// time this object was marked for deletion - int64_t nDeletionTime; + int64_t nDeletionTime{0}; /// is valid by blockchain - bool fCachedLocalValidity; + bool fCachedLocalValidity{false}; std::string strLocalValidityError; // VARIOUS FLAGS FOR OBJECT / SET VIA MASTERNODE VOTING /// true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though) - bool fCachedFunding; + bool fCachedFunding{false}; /// true == minimum network has been reached flagging this object as a valid and understood governance object (e.g, the serialized data is correct format, etc) - bool fCachedValid; + bool fCachedValid{true}; /// true == minimum network support has been reached saying this object should be deleted from the system entirely - bool fCachedDelete; + bool fCachedDelete{false}; /** true == minimum network support has been reached flagging this object as endorsed by an elected representative body * (e.g. business review board / technical review board /etc) */ - bool fCachedEndorsed; + bool fCachedEndorsed{false}; /// object was updated and cached values should be updated soon - bool fDirtyCache; + bool fDirtyCache{true}; /// Object is no longer of interest - bool fExpired; + bool fExpired{false}; /// Failed to parse object data - bool fUnparsable; + bool fUnparsable{false}; vote_m_t mapCurrentMNVotes; From 3e788edae28612e6a59c2689ce45c9b678fbc7f8 Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 12 Aug 2024 13:54:05 +0700 Subject: [PATCH 2/2] fmt: run `clang-format` --- src/governance/object.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/governance/object.cpp b/src/governance/object.cpp index 64cef52018bc0..a41fb48d00c61 100644 --- a/src/governance/object.cpp +++ b/src/governance/object.cpp @@ -28,7 +28,8 @@ CGovernanceObject::CGovernanceObject() LoadData(); } -CGovernanceObject::CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTimeIn, const uint256& nCollateralHashIn, const std::string& strDataHexIn) : +CGovernanceObject::CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTimeIn, + const uint256& nCollateralHashIn, const std::string& strDataHexIn) : cs(), m_obj{nHashParentIn, nRevisionIn, nTimeIn, nCollateralHashIn, strDataHexIn} {