-
Notifications
You must be signed in to change notification settings - Fork 1
/
spork.h
113 lines (89 loc) · 3.11 KB
/
spork.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright (c) 2015 The CBIT developers
// Copyright (c) 2009-2012 The Darkcoin 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 "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_MAX_VALUE 10002
#define SPORK_3_REPLAY_BLOCKS 10003
#define SPORK_4_NOTUSED 10004
#define SPORK_1_MASTERNODE_PAYMENTS_ENFORCEMENT_DEFAULT 1444435200 //2015-10-10 00:00:00 GMT
#define SPORK_2_MAX_VALUE_DEFAULT 13342 //13342 CBIT
#define SPORK_3_REPLAY_BLOCKS_DEFAULT 0
#define SPORK_4_RECONVERGE_DEFAULT 1420070400 //2015-01-01 00:00:00 GMT
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);
int GetSporkValue(int nSporkID);
bool IsSporkActive(int nSporkID);
void ExecuteSpork(int nSporkID, int nValue);
//
// Spork Class
// Keeps track of all of the network spork settings
//
class CSporkMessage
{
public:
std::vector<unsigned char> vchSig;
int nSporkID;
int64_t nValue;
int64_t nTimeSigned;
uint256 GetHash(){
uint256 n = Hash(BEGIN(nSporkID), END(nTimeSigned));
return n;
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
unsigned int nSerSize = 0;
READWRITE(nSporkID);
READWRITE(nValue);
READWRITE(nTimeSigned);
READWRITE(vchSig);
}
};
class CSporkManager
{
private:
std::vector<unsigned char> vchSig;
std::string strMasterPrivKey;
std::string strTestPubKey;
std::string strMainPubKey;
public:
CSporkManager() {
strMainPubKey = "0440c35f61b33eb79e68ff10c657c8455c9fa55bc6dc014dd8107ce88c87a2363d91d9991c071948ae26460f948ebf97115f93f86c6841029375d41cea6028bace";
strTestPubKey = "0440c35f61b33eb79e68ff10c657c8455c9fa55bc6dc014dd8107ce88c87a2363d91d9991c071948ae26460f948ebf97115f93f86c6841029375d41cea6028bace";
}
std::string GetSporkNameByID(int id);
int GetSporkIDByName(std::string strName);
bool UpdateSpork(int nSporkID, int64_t nValue);
bool SetPrivKey(std::string strPrivKey);
bool CheckSignature(CSporkMessage& spork);
bool Sign(CSporkMessage& spork);
void Relay(CSporkMessage& msg);
};
#endif