// Copyright (c) 2009-2012 The Dash 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 "sync.h" #include "net.h" #include "key.h" #include "util.h" #include "base58.h" #include "main.h" #include "protocol.h" #include "darksend.h" #include 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_NOTUSED 10003 #define SPORK_5_MAX_VALUE 10004 #define SPORK_6_NOTUSED 10005 #define SPORK_7_MASTERNODE_SCANNING 10006 #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_5_MAX_VALUE_DEFAULT 1000 //1000 DASH #define SPORK_7_MASTERNODE_SCANNING_DEFAULT 978307200 //2001-1-1 class CSporkMessage; class CSporkManager; extern std::map mapSporks; extern std::map 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 vchSig; int nSporkID; int64_t nValue; int64_t nTimeSigned; uint256 GetHash(){ uint256 n = HashX11(BEGIN(nSporkID), END(nTimeSigned)); return n; } ADD_SERIALIZE_METHODS; template inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(nSporkID); READWRITE(nValue); READWRITE(nTimeSigned); READWRITE(vchSig); } }; class CSporkManager { private: std::vector vchSig; std::string strMasterPrivKey; public: CSporkManager() { } 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