@@ -32,66 +32,42 @@ static constexpr int MASTERNODE_MAX_FAILED_OUTBOUND_ATTEMPTS{5};
3232// This is mostly local information, e.g. about mixing and governance
3333class CMasternodeMetaInfo
3434{
35- friend class CMasternodeMetaMan ;
36-
37- private:
38- mutable Mutex cs;
39-
40- uint256 proTxHash GUARDED_BY (cs);
35+ public:
36+ uint256 proTxHash;
4137
4238 // the dsq count from the last dsq broadcast of this node
43- std::atomic< int64_t > nLastDsq{0 };
44- std::atomic< int > nMixingTxCount{0 };
39+ int64_t nLastDsq{0 };
40+ int nMixingTxCount{0 };
4541
4642 // KEEP TRACK OF GOVERNANCE ITEMS EACH MASTERNODE HAS VOTE UPON FOR RECALCULATION
47- std::map<uint256, int > mapGovernanceObjectsVotedOn GUARDED_BY (cs) ;
43+ std::map<uint256, int > mapGovernanceObjectsVotedOn;
4844
49- std::atomic< int > outboundAttemptCount{0 };
50- std::atomic< int64_t > lastOutboundAttempt{0 };
51- std::atomic< int64_t > lastOutboundSuccess{0 };
45+ int outboundAttemptCount{0 };
46+ int64_t lastOutboundAttempt{0 };
47+ int64_t lastOutboundSuccess{0 };
5248
5349 // ! bool flag is node currently under platform ban by p2p message
54- bool m_platform_ban GUARDED_BY (cs) {false };
50+ bool m_platform_ban{false };
5551 // ! height at which platform ban has been applied or removed
56- int m_platform_ban_updated GUARDED_BY (cs) {0 };
52+ int m_platform_ban_updated{0 };
5753
5854public:
5955 CMasternodeMetaInfo () = default ;
6056 explicit CMasternodeMetaInfo (const uint256& _proTxHash) : proTxHash(_proTxHash) {}
61- CMasternodeMetaInfo (const CMasternodeMetaInfo& ref) :
62- proTxHash (ref.proTxHash),
63- nLastDsq (ref.nLastDsq.load()),
64- nMixingTxCount (ref.nMixingTxCount.load()),
65- mapGovernanceObjectsVotedOn (ref.mapGovernanceObjectsVotedOn),
66- lastOutboundAttempt (ref.lastOutboundAttempt.load()),
67- lastOutboundSuccess (ref.lastOutboundSuccess.load()),
68- m_platform_ban (ref.m_platform_ban),
69- m_platform_ban_updated (ref.m_platform_ban_updated)
70- {
71- }
57+ CMasternodeMetaInfo (const CMasternodeMetaInfo& ref) = default ;
7258
73- template <typename Stream>
74- void Serialize (Stream& s) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
59+ SERIALIZE_METHODS (CMasternodeMetaInfo, obj)
7560 {
76- LOCK (cs);
77- s << proTxHash << nLastDsq << nMixingTxCount << mapGovernanceObjectsVotedOn << outboundAttemptCount
78- << lastOutboundAttempt << lastOutboundSuccess << m_platform_ban << m_platform_ban_updated;
79- }
80-
81- template <typename Stream>
82- void Unserialize (Stream& s) EXCLUSIVE_LOCKS_REQUIRED(!cs)
83- {
84- LOCK (cs);
85- s >> proTxHash >> nLastDsq >> nMixingTxCount >> mapGovernanceObjectsVotedOn >> outboundAttemptCount >>
86- lastOutboundAttempt >> lastOutboundSuccess >> m_platform_ban >> m_platform_ban_updated;
61+ READWRITE (obj.proTxHash , obj.nLastDsq , obj.nMixingTxCount , obj.mapGovernanceObjectsVotedOn ,
62+ obj.outboundAttemptCount , obj.lastOutboundAttempt , obj.lastOutboundSuccess , obj.m_platform_ban ,
63+ obj.m_platform_ban_updated );
8764 }
8865
8966 UniValue ToJson () const EXCLUSIVE_LOCKS_REQUIRED(!cs);
9067
9168public:
9269 const uint256 GetProTxHash () const EXCLUSIVE_LOCKS_REQUIRED(!cs)
9370 {
94- LOCK (cs);
9571 return proTxHash;
9672 }
9773 int64_t GetLastDsq () const { return nLastDsq; }
@@ -111,7 +87,6 @@ class CMasternodeMetaInfo
11187 int64_t GetLastOutboundSuccess () const { return lastOutboundSuccess; }
11288 bool SetPlatformBan (bool is_banned, int height) EXCLUSIVE_LOCKS_REQUIRED(!cs)
11389 {
114- LOCK (cs);
11590 if (height < m_platform_ban_updated) {
11691 return false ;
11792 }
@@ -124,7 +99,6 @@ class CMasternodeMetaInfo
12499 }
125100 bool IsPlatformBanned () const EXCLUSIVE_LOCKS_REQUIRED(!cs)
126101 {
127- LOCK (cs);
128102 return m_platform_ban;
129103 }
130104};
0 commit comments