2016-02-02 16:28:56 +01:00
|
|
|
// Copyright (c) 2009-2012 The Dash Core developers
|
2015-02-09 21:54:51 +01:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2016-07-30 13:04:27 +02:00
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
#ifndef SPORK_H
|
|
|
|
#define SPORK_H
|
|
|
|
|
2016-02-02 16:28:56 +01:00
|
|
|
#include "hash.h"
|
2016-07-30 13:04:27 +02:00
|
|
|
#include "net.h"
|
2016-02-02 16:28:56 +01:00
|
|
|
#include "utilstrencodings.h"
|
2015-04-03 00:51:08 +02:00
|
|
|
|
2015-05-30 19:27:51 +02:00
|
|
|
/*
|
|
|
|
Don't ever reuse these IDs for other sporks
|
|
|
|
- This would result in old clients getting confused about which spork is for what
|
|
|
|
*/
|
2015-06-25 21:59:11 +02:00
|
|
|
#define SPORK_START 10001
|
2015-07-17 05:03:42 +02:00
|
|
|
#define SPORK_END 10012
|
2015-06-25 21:59:11 +02:00
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
#define SPORK_2_INSTANTX 10001
|
|
|
|
#define SPORK_3_INSTANTX_BLOCK_FILTERING 10002
|
2015-02-11 15:47:21 +01:00
|
|
|
#define SPORK_5_MAX_VALUE 10004
|
2015-03-13 10:28:20 +01:00
|
|
|
#define SPORK_7_MASTERNODE_SCANNING 10006
|
2015-05-30 19:27:51 +02:00
|
|
|
#define SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT 10007
|
|
|
|
#define SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT 10008
|
2015-07-27 17:27:58 +02:00
|
|
|
#define SPORK_10_MASTERNODE_PAY_UPDATED_NODES 10009
|
2015-07-08 19:25:47 +02:00
|
|
|
#define SPORK_11_RESET_BUDGET 10010
|
2015-07-16 20:06:45 +02:00
|
|
|
#define SPORK_12_RECONSIDER_BLOCKS 10011
|
2015-07-17 05:03:42 +02:00
|
|
|
#define SPORK_13_ENABLE_SUPERBLOCKS 10012
|
2015-02-09 21:54:51 +01:00
|
|
|
|
|
|
|
#define SPORK_2_INSTANTX_DEFAULT 978307200 //2001-1-1
|
|
|
|
#define SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18
|
2015-03-18 00:06:58 +01:00
|
|
|
#define SPORK_5_MAX_VALUE_DEFAULT 1000 //1000 DASH
|
2015-03-13 10:28:20 +01:00
|
|
|
#define SPORK_7_MASTERNODE_SCANNING_DEFAULT 978307200 //2001-1-1
|
2015-08-09 02:27:38 +02:00
|
|
|
#define SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT 4070908800 //OFF
|
|
|
|
#define SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT 4070908800 //OFF
|
|
|
|
#define SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT 4070908800 //OFF
|
2015-07-08 19:25:47 +02:00
|
|
|
#define SPORK_11_RESET_BUDGET_DEFAULT 0
|
2015-07-16 20:06:45 +02:00
|
|
|
#define SPORK_12_RECONSIDER_BLOCKS_DEFAULT 0
|
2015-08-09 19:49:14 +02:00
|
|
|
#define SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT 4070908800 //OFF
|
2016-07-30 13:04:27 +02:00
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
class CSporkMessage;
|
|
|
|
class CSporkManager;
|
|
|
|
|
|
|
|
extern std::map<uint256, CSporkMessage> mapSporks;
|
|
|
|
extern CSporkManager sporkManager;
|
|
|
|
|
|
|
|
//
|
2016-07-30 13:04:27 +02:00
|
|
|
// Spork classes
|
|
|
|
// Keep track of all of the network spork settings
|
2015-02-09 21:54:51 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
class CSporkMessage
|
|
|
|
{
|
2016-07-30 13:04:27 +02:00
|
|
|
private:
|
2015-02-09 21:54:51 +01:00
|
|
|
std::vector<unsigned char> vchSig;
|
2016-07-30 13:04:27 +02:00
|
|
|
|
|
|
|
public:
|
2015-02-09 21:54:51 +01:00
|
|
|
int nSporkID;
|
2015-02-11 15:47:21 +01:00
|
|
|
int64_t nValue;
|
2015-02-09 21:54:51 +01:00
|
|
|
int64_t nTimeSigned;
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
CSporkMessage(int nSporkID, int64_t nValue, int64_t nTimeSigned) : nSporkID(nSporkID), nValue(nValue), nTimeSigned(nTimeSigned) {}
|
|
|
|
CSporkMessage() : nSporkID(0), nValue(0), nTimeSigned(0) {}
|
|
|
|
|
|
|
|
uint256 GetHash() { return HashX11(BEGIN(nSporkID), END(nTimeSigned)); }
|
|
|
|
bool Sign(std::string strSignKey);
|
|
|
|
bool CheckSignature();
|
|
|
|
void Relay();
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2015-04-03 00:51:08 +02:00
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
|
|
|
|
template <typename Stream, typename Operation>
|
|
|
|
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
2015-02-09 21:54:51 +01:00
|
|
|
READWRITE(nSporkID);
|
2015-02-11 15:47:21 +01:00
|
|
|
READWRITE(nValue);
|
2015-02-09 21:54:51 +01:00
|
|
|
READWRITE(nTimeSigned);
|
|
|
|
READWRITE(vchSig);
|
2015-04-03 00:51:08 +02:00
|
|
|
}
|
2015-02-09 21:54:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CSporkManager
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector<unsigned char> vchSig;
|
|
|
|
std::string strMasterPrivKey;
|
2016-07-30 13:04:27 +02:00
|
|
|
std::map<int, CSporkMessage> mapSporksActive;
|
2015-02-09 21:54:51 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
CSporkManager() {}
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
|
|
|
void ExecuteSpork(int nSporkID, int nValue);
|
2015-02-11 15:47:21 +01:00
|
|
|
bool UpdateSpork(int nSporkID, int64_t nValue);
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
bool IsSporkActive(int nSporkID);
|
|
|
|
int64_t GetSporkValue(int nSporkID);
|
|
|
|
int GetSporkIDByName(std::string strName);
|
|
|
|
std::string GetSporkNameByID(int nSporkID);
|
|
|
|
|
|
|
|
bool SetPrivKey(std::string strPrivKey);
|
2015-02-09 21:54:51 +01:00
|
|
|
};
|
|
|
|
|
2015-04-03 00:51:08 +02:00
|
|
|
#endif
|