Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
•All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
spork.cpp
Go to the documentation of this file.
114 void CSporkManager::ProcessSpork(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman)
129 strLogMsg = strprintf("SPORK -- hash: %s id: %d value: %10d bestHeight: %d peer=%d", hash.ToString(), spork.nSporkID, spork.nValue, chainActive.Height(), pfrom->GetId());
178 connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::SPORK, signerSporkPair.second));
202 LogPrintf("CSporkManager::%s -- signed %d %s\n", __func__, nSporkID, spork.GetHash().ToString());
239 LogPrint(BCLog::SPORK, "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
285 LogPrintf("CSporkManager::SetMinSporkKeys -- Invalid min spork signers number: %d\n", minSporkKeys);
363 std::string strMessage = std::to_string(nSporkID) + std::to_string(nValue) + std::to_string(nTimeSigned);
388 LogPrint(BCLog::SPORK, "CSporkMessage::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
392 std::string strMessage = std::to_string(nSporkID) + std::to_string(nValue) + std::to_string(nTimeSigned);
395 LogPrint(BCLog::SPORK, "CSporkMessage::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
412 std::string strMessage = std::to_string(nSporkID) + std::to_string(nValue) + std::to_string(nTimeSigned);
static bool VerifyHash(const uint256 &hash, const CPubKey &pubkey, const std::vector< unsigned char > &vchSig, std::string &strErrorRet)
Verify the hash signature, returns true if succcessful.
Definition: messagesigner.cpp:52
Definition: spork.h:28
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:80
bool UpdateSpork(SporkId nSporkID, int64_t nValue, CConnman &connman)
UpdateSpork is used by the spork RPC command to set a new spork value, sign and broadcast the spork m...
Definition: spork.cpp:185
bool Sign(const CKey &key)
Sign will sign the spork message with the given key.
Definition: spork.cpp:339
static bool SignHash(const uint256 &hash, const CKey &key, std::vector< unsigned char > &vchSigRet)
Sign the hash, returns true if successful.
Definition: messagesigner.cpp:47
SporkId GetSporkIDByName(const std::string &strName)
GetSporkIDByName returns the internal Spork ID given the spork name.
Definition: spork.cpp:235
void PushMessage(CNode *pnode, CSerializedNetMsg &&msg)
Definition: net.cpp:3733
void ProcessSpork(CNode *pfrom, const std::string &strCommand, CDataStream &vRecv, CConnman &connman)
ProcessSpork is used to handle the 'getsporks' and 'spork' p2p messages.
Definition: spork.cpp:114
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
Definition: util.h:143
uint256 GetSignatureHash() const
GetSignatureHash returns the hash of the serialized spork message without the signature included...
Definition: spork.cpp:330
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:149
Sporks are network parameters used primarily to prevent forking and turn on/off certain features...
Definition: spork.h:75
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.
Definition: messagesigner.cpp:33
std::string ToString() const
ToString returns the string representation of the SporkManager.
Definition: spork.cpp:319
Definition: spork.h:24
bool SetSporkAddress(const std::string &strAddress)
SetSporkAddress is used to set a public key ID which will be used to verify spork signatures...
Definition: spork.cpp:269
static bool SignMessage(const std::string &strMessage, std::vector< unsigned char > &vchSigRet, const CKey &key)
Sign the message, returns true if successful.
Definition: messagesigner.cpp:24
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
Definition: hash.h:254
void Misbehaving(NodeId pnode, int howmuch, const std::string &message)
Increase a node's misbehavior score.
Definition: net_processing.cpp:1024
Definition: spork.h:32
std::unordered_map< SporkId, std::map< CKeyID, CSporkMessage > > mapSporksActive
Definition: spork.h:161
void CheckAndRemove()
CheckAndRemove is defined to fulfill an interface as part of the on-disk cache used to cache sporks b...
Definition: spork.cpp:69
Definition: spork.h:27
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
Definition: pubkey.cpp:186
CSporkManager is a higher-level class which manages the node's spork messages, rules for which sporks...
Definition: spork.h:151
int64_t GetSporkValue(SporkId nSporkID)
GetSporkValue returns the spork value given a Spork ID.
Definition: spork.cpp:217
bool GetSporkByHash(const uint256 &hash, CSporkMessage &sporkRet)
GetSporkByHash returns a spork message given a hash of the spork message.
Definition: spork.cpp:255
std::string GetSporkNameByID(SporkId nSporkID)
GetSporkNameByID returns the spork name as a string, given a Spork ID.
Definition: spork.cpp:245
static const std::string SERIALIZATION_VERSION_STRING
Definition: spork.h:154
Definition: protocol.h:407
Definition: spork.h:26
uint256 GetHash() const
GetHash returns the double-sha256 hash of the serialized spork message.
Definition: spork.cpp:325
Definition: spork.h:25
static bool GetKeysFromSecret(const std::string &strSecret, CKey &keyRet, CPubKey &pubkeyRet)
Set the private/public key values, returns true if successful.
Definition: messagesigner.cpp:12
std::unordered_map< uint256, CSporkMessage > mapSporksByHash
Definition: spork.h:160
bool GetSignerKeyID(CKeyID &retKeyidSporkSigner)
GetSignerKeyID is used to recover the spork address of the key used to sign this spork message...
Definition: spork.cpp:403
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:947
void Relay(CConnman &connman)
Relay is used to send this spork message to other peers.
Definition: spork.cpp:425
bool CheckSignature(const CKeyID &pubKeyId) const
CheckSignature will ensure the spork signature matches the provided public key hash.
Definition: spork.cpp:379
std::unordered_map< std::string, CSporkDef * > sporkDefsByName
Definition: spork.h:157
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:453
Definition: netmessagemaker.h:12
void RelayInv(CInv &inv, const int minProtoVersion=MIN_PEER_PROTO_VERSION, bool fAllowMasternodeConnections=false)
Definition: net.cpp:3482
void EraseObjectRequest(CNodeState *nodestate, const CInv &inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: net_processing.cpp:676
bool SporkValueIsActive(SporkId nSporkID, int64_t &nActiveValueRet) const
SporkValueIsActive is used to get the value agreed upon by the majority of signed spork messages for ...
Definition: spork.cpp:39
bool IsSporkActive(SporkId nSporkID)
IsSporkActive returns a bool for time-based sporks, and should be used to determine whether the spork...
Definition: spork.cpp:211
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:217
Definition: spork.h:30
bool SetMinSporkKeys(int minSporkKeys)
SetMinSporkKeys is used to set the required spork signer threshold, for a spork to be considered acti...
Definition: spork.cpp:281
bool SetPrivKey(const std::string &strPrivKey)
SetPrivKey is used to set a spork key to enable setting / signing of spork values.
Definition: spork.cpp:292
Definition: serialize.h:162
std::unordered_map< SporkId, CSporkDef * > sporkDefsById
Definition: spork.h:156
Definition: spork.h:29