14 #define MAKE_SPORK_DEF(name, defaultValue) CSporkDef(name, defaultValue, #name)
53 LogPrintf(
"%s : no previous value for %s found in database\n", __func__, sporkDef.name);
59 LogPrintf(
"%s : Spork 15 signed at %d\n", __func__,
spork.nTimeSigned);
65 if (
spork.nTimeSigned <= 1578338986 ) {
66 LogPrintf(
"%s : Stale spork 15 detected, clearing...\n", __func__);
75 std::time_t result =
spork.nValue;
78 if (
spork.nValue > 1000000) {
79 char* res = std::ctime(&result);
80 LogPrintf(
"%s : loaded spork %s with value %d : %s\n", __func__, sporkName.c_str(),
spork.nValue,
81 ((res) ? res :
"no time") );
83 LogPrintf(
"%s : loaded spork %s with value %d\n", __func__,
84 sporkName,
spork.nValue);
112 if (strSpork ==
"Unknown")
return 0;
127 std::string strStatus;
135 spork.nSporkID, sporkName,
140 strStatus =
"updated";
149 bool fValidSig =
spork.CheckSignature(
spork.GetPublicKey().GetID());
150 if (!fValidSig && !fRequireNew) {
154 fValidSig =
spork.CheckSignature(pubkeyold.
GetID());
164 LogPrintf(
"%s : got %s spork %d (%s) with value %d (signed at %d)\n", __func__,
165 strStatus,
spork.nSporkID, sporkName,
spork.nValue,
spork.nTimeSigned);
178 std::map<SporkId, CSporkMessage>::iterator it =
mapSporksActive.begin();
186 if (
Params().IsRegTestNet()) {
236 return it->second->defaultValue;
238 LogPrintf(
"%s : Unknown Spork %d\n", __func__, nSporkID);
249 LogPrintf(
"%s : Unknown Spork name '%s'\n", __func__, strName);
252 return it->second->sporkId;
262 return it->second->name;
269 spork.Sign(strPrivKey);
271 bool fValidSig =
spork.CheckSignature(
spork.GetPublicKey().GetID());
276 fValidSig =
spork.CheckSignature(pubkeyold.
GetID());
282 LogPrintf(
"%s : Successfully initialized as spork signer\n", __func__);
const CChainParams & Params()
Return the currently selected parameters.
const Consensus::Params & GetConsensus() const
A writer stream (for serialization) that computes a 256-bit hash.
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args &&... args)
Information about a peer.
int GetSendVersion() const
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
void ProcessGetSporks(CNode *pfrom, std::string &strCommand, CDataStream &vRecv)
std::string strMasterPrivKey
std::map< SporkId, CSporkMessage > mapSporksActive
bool UpdateSpork(SporkId nSporkID, int64_t nValue)
std::map< std::string, CSporkDef * > sporkDefsByName
bool SetPrivKey(std::string strPrivKey)
SporkId GetSporkIDByName(std::string strName)
std::string GetSporkNameByID(SporkId id)
std::map< SporkId, CSporkDef * > sporkDefsById
std::string ToString() const
int64_t GetSporkValue(SporkId nSporkID)
bool ProcessSpork(CNode *pfrom, std::string &strCommand, CDataStream &vRecv, int &dosScore)
int ProcessSporkMsg(CDataStream &vRecv)
bool IsSporkActive(SporkId nSporkID)
void AddOrUpdateSporkMessage(const CSporkMessage &spork, bool flush=false)
uint256 GetSignatureHash() const override
const CPubKey GetPublicKey() const
const CPubKey GetPublicKeyOld() const
std::string GetStrMessage() const override
std::unique_ptr< CConnman > g_connman
#define LogPrint(category,...)
UniValue spork(const JSONRPCRequest &request)
const char * SPORK
The spork message is used to send spork values to connected peers.
const char * GETSPORKS
The getsporks message is used to request spork data from connected peers.
#define MAKE_SPORK_DEF(name, defaultValue)
std::vector< CSporkDef > sporkDefs
std::map< uint256, CSporkMessage > mapSporks
CSporkManager sporkManager
@ SPORK_23_CHAINLOCKS_ENFORCEMENT
@ SPORK_22_LLMQ_DKG_MAINTENANCE
@ SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2
@ SPORK_14_NEW_PROTOCOL_ENFORCEMENT
@ SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT
@ SPORK_13_ENABLE_SUPERBLOCKS
@ SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT
@ SPORK_19_COLDSTAKING_MAINTENANCE
@ SPORK_20_SAPLING_MAINTENANCE
@ SPORK_21_LEGACY_MNS_MAX_HEIGHT
int64_t nTime_EnforceNewSporkKey
int64_t GetAdjustedTime()
std::vector< unsigned char > ParseHex(const char *psz)
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
std::unique_ptr< CSporkDB > pSporkDB
Global variable that points to the spork database (protected by cs_main)