mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
107 lines
2.9 KiB
C
107 lines
2.9 KiB
C
|
|
||
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||
|
// Copyright (c) 2009-2012 The Bitcoin developers
|
||
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||
|
#ifndef SPORK_H
|
||
|
#define SPORK_H
|
||
|
|
||
|
#include "bignum.h"
|
||
|
#include "sync.h"
|
||
|
#include "net.h"
|
||
|
#include "key.h"
|
||
|
#include "core.h"
|
||
|
#include "util.h"
|
||
|
#include "script.h"
|
||
|
#include "base58.h"
|
||
|
#include "main.h"
|
||
|
|
||
|
using namespace std;
|
||
|
using namespace boost;
|
||
|
|
||
|
// Don't ever reuse these IDs for other sporks
|
||
|
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT 10000
|
||
|
#define SPORK_2_INSTANTX 10001
|
||
|
#define SPORK_3_INSTANTX_BLOCK_FILTERING 10002
|
||
|
#define SPORK_4_RECONVERGE 10003
|
||
|
|
||
|
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 1424217600 //2015-2-18
|
||
|
#define SPORK_2_INSTANTX_DEFAULT 978307200 //2001-1-1
|
||
|
#define SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18
|
||
|
#define SPORK_4_RECONVERGE_DEFAULT 4070908800 //2099-1-1
|
||
|
|
||
|
class CSporkMessage;
|
||
|
class CSporkManager;
|
||
|
|
||
|
#include "bignum.h"
|
||
|
#include "net.h"
|
||
|
#include "key.h"
|
||
|
#include "util.h"
|
||
|
#include "protocol.h"
|
||
|
#include "darksend.h"
|
||
|
#include <boost/lexical_cast.hpp>
|
||
|
|
||
|
using namespace std;
|
||
|
using namespace boost;
|
||
|
|
||
|
extern std::map<uint256, CSporkMessage> mapSporks;
|
||
|
extern std::map<int, CSporkMessage> mapSporksActive;
|
||
|
extern CSporkManager sporkManager;
|
||
|
|
||
|
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||
|
bool IsSporkActive(int nSporkID);
|
||
|
|
||
|
//
|
||
|
// Spork Class
|
||
|
// Keeps track of all of the network spork settings
|
||
|
//
|
||
|
|
||
|
class CSporkMessage
|
||
|
{
|
||
|
public:
|
||
|
std::vector<unsigned char> vchSig;
|
||
|
int nSporkID;
|
||
|
int64_t nTimeStart;
|
||
|
int64_t nTimeSigned;
|
||
|
|
||
|
uint256 GetHash(){
|
||
|
uint256 n = HashX11(BEGIN(nSporkID), END(nTimeSigned));
|
||
|
return n;
|
||
|
}
|
||
|
|
||
|
IMPLEMENT_SERIALIZE(
|
||
|
READWRITE(nSporkID);
|
||
|
READWRITE(nTimeStart);
|
||
|
READWRITE(nTimeSigned);
|
||
|
READWRITE(vchSig);
|
||
|
)
|
||
|
};
|
||
|
|
||
|
|
||
|
class CSporkManager
|
||
|
{
|
||
|
private:
|
||
|
std::vector<unsigned char> vchSig;
|
||
|
|
||
|
std::string strMasterPrivKey;
|
||
|
std::string strTestPubKey;
|
||
|
std::string strMainPubKey;
|
||
|
|
||
|
public:
|
||
|
|
||
|
CSporkManager() {
|
||
|
strMainPubKey = "04549ac134f694c0243f503e8c8a9a986f5de6610049c40b07816809b0d1d06a21b07be27b9bb555931773f62ba6cf35a25fd52f694d4e1106ccd237a7bb899fdd";
|
||
|
strTestPubKey = "046f78dcf911fbd61910136f7f0f8d90578f68d0b3ac973b5040fb7afb501b5939f39b108b0569dca71488f5bbf498d92e4d1194f6f941307ffd95f75e76869f0e";
|
||
|
}
|
||
|
|
||
|
std::string GetSporkNameByID(int id);
|
||
|
int GetSporkIDByName(std::string strName);
|
||
|
bool UpdateSpork(int nSporkID, int64_t nTimeStart);
|
||
|
bool SetPrivKey(std::string strPrivKey);
|
||
|
bool CheckSignature(CSporkMessage& spork);
|
||
|
bool Sign(CSporkMessage& spork);
|
||
|
void Relay(CSporkMessage& msg);
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif
|