11 #include <boost/lexical_cast.hpp> 31 std::string strLogMsg;
41 LogPrint(
"spork",
"%s seen\n", strLogMsg);
50 if(!
spork.CheckSignature()) {
51 LogPrintf(
"CSporkManager::ProcessSpork -- invalid signature\n");
80 int64_t nMaxBlocks = 576;
82 int64_t nTimeout = 10 * 60;
84 static int64_t nTimeExecuted = 0;
86 if(
GetTime() - nTimeExecuted < nTimeout) {
87 LogPrint(
"spork",
"CSporkManager::ExecuteSpork -- ERROR: Trying to reconsider blocks, too soon - %d/%d\n",
GetTime() - nTimeExecuted, nTimeout);
91 if(nValue > nMaxBlocks) {
92 LogPrintf(
"CSporkManager::ExecuteSpork -- ERROR: Trying to reconsider too many blocks %d/%d\n", nValue, nMaxBlocks);
97 LogPrintf(
"CSporkManager::ExecuteSpork -- Reconsider Last %d Blocks\n", nValue);
110 spork.Relay(connman);
138 LogPrint(
"spork",
"CSporkManager::IsSporkActive -- Unknown Spork ID %d\n", nSporkID);
164 LogPrint(
"spork",
"CSporkManager::GetSporkValue -- Unknown Spork ID %d\n", nSporkID);
182 LogPrint(
"spork",
"CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
199 LogPrint(
"spork",
"CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
208 spork.Sign(strPrivKey);
210 if(
spork.CheckSignature()){
212 LogPrintf(
"CSporkManager::SetPrivKey -- Successfully initialized as spork signer\n");
224 std::string strError =
"";
225 std::string strMessage = boost::lexical_cast<std::string>(
nSporkID) + boost::lexical_cast<std::string>(
nValue) + boost::lexical_cast<std::string>(
nTimeSigned);
228 LogPrintf(
"CSporkMessage::Sign -- GetKeysFromSecret() failed, invalid spork key %s\n", strSignKey);
233 LogPrintf(
"CSporkMessage::Sign -- SignMessage() failed\n");
238 LogPrintf(
"CSporkMessage::Sign -- VerifyMessage() failed, error: %s\n", strError);
248 std::string strError =
"";
249 std::string strMessage = boost::lexical_cast<std::string>(
nSporkID) + boost::lexical_cast<std::string>(
nValue) + boost::lexical_cast<std::string>(
nTimeSigned);
253 LogPrintf(
"CSporkMessage::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
void ProcessSpork(CNode *pfrom, std::string &strCommand, CDataStream &vRecv, CConnman &connman)
static const int64_t SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT
UniValue spork(const UniValue ¶ms, bool fHelp)
static const int64_t SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT
static const int64_t SPORK_5_INSTANTSEND_MAX_VALUE_DEFAULT
static const int SPORK_10_MASTERNODE_PAY_UPDATED_NODES
std::set< uint256 > setAskFor
static const int SPORK_3_INSTANTSEND_BLOCK_FILTERING
static const int SPORK_5_INSTANTSEND_MAX_VALUE
std::vector< unsigned char > vchSig
static const int SPORK_9_SUPERBLOCKS_ENABLED
void RelayInv(CInv &inv, const int minProtoVersion=MIN_PEER_PROTO_VERSION)
int GetSporkIDByName(std::string strName)
std::string GetSporkNameByID(int nSporkID)
static bool GetKeysFromSecret(const std::string strSecret, CKey &keyRet, CPubKey &pubkeyRet)
Set the private/public key values, returns true if successful.
void Misbehaving(NodeId pnode, int howmuch)
static int LogPrint(const char *category, const char *format)
std::map< int, CSporkMessage > mapSporksActive
static const int SPORK_13_OLD_SUPERBLOCK_FLAG
std::string strMasterPrivKey
static const int SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT
bool Sign(std::string strSignKey)
vector< unsigned char > ParseHex(const char *psz)
void Relay(CConnman &connman)
static bool VerifyMessage(const CPubKey pubkey, const std::vector< unsigned char > &vchSig, const std::string strMessage, std::string &strErrorRet)
Verify the message signature, returns true if succcessful.
std::string ToString() const
static const int SPORK_12_RECONSIDER_BLOCKS
bool UpdateSpork(int nSporkID, int64_t nValue, CConnman &connman)
CSporkManager sporkManager
static const int SPORK_14_REQUIRE_SENTINEL_FLAG
static const int64_t SPORK_13_OLD_SUPERBLOCK_FLAG_DEFAULT
static const int64_t SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT
const CChainParams & Params()
int64_t GetAdjustedTime()
static const int64_t SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT
void ExecuteSpork(int nSporkID, int nValue)
CBlockIndex * Tip() const
static const int64_t SPORK_2_INSTANTSEND_ENABLED_DEFAULT
bool SetPrivKey(std::string strPrivKey)
static bool SignMessage(const std::string strMessage, std::vector< unsigned char > &vchSigRet, const CKey key)
Sign the message, returns true if successful.
bool IsSporkActive(int nSporkID)
static const int64_t SPORK_12_RECONSIDER_BLOCKS_DEFAULT
int64_t GetTime()
For unit testing.
int64_t GetSporkValue(int nSporkID)
static const int SPORK_2_INSTANTSEND_ENABLED
std::map< uint256, CSporkMessage > mapSporks
void PushMessage(CNode *pnode, const std::string &sCommand, Args &&... args)
static const int64_t SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT
void ReprocessBlocks(int nBlocks)