LCOV - code coverage report
Current view: top level - src/active - masternode.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 4 4 100.0 %
Date: 2026-06-25 07:23:43 Functions: 4 4 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2014-2025 The Dash Core developers
       2             : // Distributed under the MIT/X11 software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_ACTIVE_MASTERNODE_H
       6             : #define BITCOIN_ACTIVE_MASTERNODE_H
       7             : 
       8             : #include <bls/bls.h>
       9             : 
      10             : #include <netaddress.h>
      11             : #include <primitives/transaction.h>
      12             : #include <threadsafety.h>
      13             : #include <validationinterface.h>
      14             : 
      15             : class CConnman;
      16             : class CDeterministicMNManager;
      17             : 
      18             : class CActiveMasternodeManager
      19             : {
      20             : private:
      21             :     CConnman& m_connman;
      22             :     CDeterministicMNManager& m_dmnman;
      23             :     const CBLSPublicKey m_operator_pk;
      24             :     const CBLSSecretKey m_operator_sk;
      25             : 
      26             : private:
      27             :     enum class MasternodeState {
      28             :         WAITING_FOR_PROTX,
      29             :         POSE_BANNED,
      30             :         REMOVED,
      31             :         OPERATOR_KEY_CHANGED,
      32             :         PROTX_IP_CHANGED,
      33             :         READY,
      34             :         SOME_ERROR,
      35             :     };
      36             : 
      37             :     mutable SharedMutex cs;
      38             :     COutPoint m_outpoint GUARDED_BY(cs);
      39             :     CService m_service GUARDED_BY(cs);
      40             :     MasternodeState m_state GUARDED_BY(cs){MasternodeState::WAITING_FOR_PROTX};
      41             :     std::string m_error GUARDED_BY(cs);
      42             :     uint256 m_protx_hash GUARDED_BY(cs);
      43             : 
      44             : public:
      45             :     CActiveMasternodeManager() = delete;
      46             :     CActiveMasternodeManager(const CActiveMasternodeManager&) = delete;
      47             :     CActiveMasternodeManager& operator=(const CActiveMasternodeManager&) = delete;
      48             :     explicit CActiveMasternodeManager(CConnman& connman, CDeterministicMNManager& dmnman, const CBLSSecretKey& sk);
      49             :     ~CActiveMasternodeManager();
      50             : 
      51             :     void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
      52             :         EXCLUSIVE_LOCKS_REQUIRED(!cs);
      53             : 
      54        3173 :     void Init(const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs) { LOCK(cs); InitInternal(pindex); };
      55             : 
      56             :     std::string GetStateString() const;
      57             :     std::string GetStatus() const;
      58             : 
      59             :     static bool IsValidNetAddr(const CService& addrIn);
      60             : 
      61             :     template <template <typename> class EncryptedObj, typename Obj>
      62             :     [[nodiscard]] bool Decrypt(const EncryptedObj<Obj>& obj, size_t idx, Obj& ret_obj, int version) const
      63             :         EXCLUSIVE_LOCKS_REQUIRED(!cs);
      64             :     [[nodiscard]] CBLSSignature Sign(const uint256& hash, const bool is_legacy) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
      65             :     [[nodiscard]] std::vector<uint8_t> SignBasic(const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
      66             : 
      67         799 :     [[nodiscard]] COutPoint GetOutPoint() const { READ_LOCK(cs); return m_outpoint; }
      68      761422 :     [[nodiscard]] uint256 GetProTxHash() const { READ_LOCK(cs); return m_protx_hash; }
      69          12 :     [[nodiscard]] CService GetService() const { READ_LOCK(cs); return m_service; }
      70             :     [[nodiscard]] CBLSPublicKey GetPubKey() const;
      71             : 
      72             : private:
      73             :     void InitInternal(const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs);
      74             :     bool GetLocalAddress(CService& addrRet) EXCLUSIVE_LOCKS_REQUIRED(cs);
      75             : };
      76             : 
      77             : #endif // BITCOIN_ACTIVE_MASTERNODE_H

Generated by: LCOV version 1.16