2021-04-20 21:33:02 +02:00
|
|
|
// Copyright (c) 2014-2021 The Dash Core developers
|
2014-12-09 02:17:57 +01:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2016-08-05 21:49:45 +02:00
|
|
|
|
2021-10-01 21:19:08 +02:00
|
|
|
#ifndef BITCOIN_MASTERNODE_NODE_H
|
|
|
|
#define BITCOIN_MASTERNODE_NODE_H
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2021-10-25 15:55:34 +02:00
|
|
|
#include <netaddress.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <primitives/transaction.h>
|
|
|
|
#include <validationinterface.h>
|
2018-02-15 14:33:04 +01:00
|
|
|
|
2021-04-16 05:41:16 +02:00
|
|
|
class CBLSPublicKey;
|
|
|
|
class CBLSSecretKey;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2018-08-11 21:55:56 +02:00
|
|
|
struct CActiveMasternodeInfo;
|
2019-01-03 21:08:34 +01:00
|
|
|
class CActiveMasternodeManager;
|
2016-08-05 21:49:45 +02:00
|
|
|
|
2018-08-11 21:55:56 +02:00
|
|
|
extern CActiveMasternodeInfo activeMasternodeInfo;
|
2021-07-26 17:52:52 +02:00
|
|
|
extern CCriticalSection activeMasternodeInfoCs;
|
2019-01-03 21:08:34 +01:00
|
|
|
extern CActiveMasternodeManager* activeMasternodeManager;
|
2018-08-11 21:55:56 +02:00
|
|
|
|
|
|
|
struct CActiveMasternodeInfo {
|
|
|
|
// Keys for the active Masternode
|
2018-10-21 21:45:16 +02:00
|
|
|
std::unique_ptr<CBLSPublicKey> blsPubKeyOperator;
|
|
|
|
std::unique_ptr<CBLSSecretKey> blsKeyOperator;
|
2018-08-11 21:55:56 +02:00
|
|
|
|
|
|
|
// Initialized while registering Masternode
|
2018-11-23 16:33:45 +01:00
|
|
|
uint256 proTxHash;
|
2018-08-11 21:55:56 +02:00
|
|
|
COutPoint outpoint;
|
|
|
|
CService service;
|
|
|
|
};
|
2015-07-17 12:26:24 +02:00
|
|
|
|
2018-02-15 14:33:04 +01:00
|
|
|
|
2019-01-03 21:08:34 +01:00
|
|
|
class CActiveMasternodeManager : public CValidationInterface
|
2018-02-15 14:33:04 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum masternode_state_t {
|
|
|
|
MASTERNODE_WAITING_FOR_PROTX,
|
|
|
|
MASTERNODE_POSE_BANNED,
|
|
|
|
MASTERNODE_REMOVED,
|
2018-12-10 06:04:13 +01:00
|
|
|
MASTERNODE_OPERATOR_KEY_CHANGED,
|
2019-10-30 20:31:13 +01:00
|
|
|
MASTERNODE_PROTX_IP_CHANGED,
|
2018-02-15 14:33:04 +01:00
|
|
|
MASTERNODE_READY,
|
|
|
|
MASTERNODE_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
masternode_state_t state{MASTERNODE_WAITING_FOR_PROTX};
|
|
|
|
std::string strError;
|
|
|
|
|
|
|
|
public:
|
2021-08-06 23:55:51 +02:00
|
|
|
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override;
|
2018-02-15 14:33:04 +01:00
|
|
|
|
2020-03-20 17:11:54 +01:00
|
|
|
void Init(const CBlockIndex* pindex);
|
2018-02-15 14:33:04 +01:00
|
|
|
|
|
|
|
std::string GetStateString() const;
|
|
|
|
std::string GetStatus() const;
|
|
|
|
|
2019-01-03 10:17:43 +01:00
|
|
|
static bool IsValidNetAddr(CService addrIn);
|
2016-10-17 20:54:28 +02:00
|
|
|
|
2015-07-14 07:25:07 +02:00
|
|
|
private:
|
2019-01-03 10:17:43 +01:00
|
|
|
bool GetLocalAddress(CService& addrRet);
|
2014-12-09 02:17:57 +01:00
|
|
|
};
|
|
|
|
|
2021-10-01 21:19:08 +02:00
|
|
|
#endif // BITCOIN_MASTERNODE_NODE_H
|