Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Sporks are network parameters used primarily to prevent forking and turn on/off certain features. More...
#include <spork.h>
Public Member Functions | |
CSporkMessage (SporkId nSporkID, int64_t nValue, int64_t nTimeSigned) | |
CSporkMessage () | |
template<typename Stream , typename Operation > | |
void | SerializationOp (Stream &s, Operation ser_action) |
uint256 | GetHash () const |
GetHash returns the double-sha256 hash of the serialized spork message. More... | |
uint256 | GetSignatureHash () const |
GetSignatureHash returns the hash of the serialized spork message without the signature included. More... | |
bool | Sign (const CKey &key) |
Sign will sign the spork message with the given key. More... | |
bool | CheckSignature (const CKeyID &pubKeyId) const |
CheckSignature will ensure the spork signature matches the provided public key hash. More... | |
bool | GetSignerKeyID (CKeyID &retKeyidSporkSigner) |
GetSignerKeyID is used to recover the spork address of the key used to sign this spork message. More... | |
void | Relay (CConnman &connman) |
Relay is used to send this spork message to other peers. More... | |
Public Attributes | |
SporkId | nSporkID |
int64_t | nValue |
int64_t | nTimeSigned |
ADD_SERIALIZE_METHODS | |
Private Attributes | |
std::vector< unsigned char > | vchSig |
Detailed Description
Sporks are network parameters used primarily to prevent forking and turn on/off certain features.
They are a soft consensus mechanism.
We use 2 main classes to manage the spork system.
SporkMessages - low-level constructs which contain the sporkID, value, signature and a signature timestamp SporkManager - a higher-level construct which manages the naming, use of sporks, signatures and verification, and which sporks are active according to this node CSporkMessage is a low-level class used to encapsulate Spork messages and serialize them for transmission to other peers. This includes the internal spork ID, value, spork signature and timestamp for the signature.
Constructor & Destructor Documentation
◆ CSporkMessage() [1/2]
|
inline |
◆ CSporkMessage() [2/2]
Member Function Documentation
◆ CheckSignature()
bool CSporkMessage::CheckSignature | ( | const CKeyID & | pubKeyId | ) | const |
CheckSignature will ensure the spork signature matches the provided public key hash.
Definition at line 379 of file spork.cpp.
References GetSignatureHash(), LogPrint, nSporkID, nTimeSigned, nValue, Params(), BCLog::SPORK, CBaseChainParams::TESTNET, vchSig, CHashSigner::VerifyHash(), and CMessageSigner::VerifyMessage().
◆ GetHash()
uint256 CSporkMessage::GetHash | ( | ) | const |
GetHash returns the double-sha256 hash of the serialized spork message.
Definition at line 325 of file spork.cpp.
References SerializeHash().
Referenced by Relay().
◆ GetSignatureHash()
uint256 CSporkMessage::GetSignatureHash | ( | ) | const |
GetSignatureHash returns the hash of the serialized spork message without the signature included.
The intent of this method is to get the hash to be signed.
Definition at line 330 of file spork.cpp.
References CHashWriter::GetHash(), nSporkID, nTimeSigned, nValue, and SER_GETHASH.
Referenced by CheckSignature(), GetSignerKeyID(), and Sign().
◆ GetSignerKeyID()
bool CSporkMessage::GetSignerKeyID | ( | CKeyID & | retKeyidSporkSigner | ) |
GetSignerKeyID is used to recover the spork address of the key used to sign this spork message.
This method was introduced along with the multi-signer sporks feature, in order to identify which spork key signed this message.
Definition at line 403 of file spork.cpp.
References CHashWriter::GetHash(), CPubKey::GetID(), GetSignatureHash(), nSporkID, nTimeSigned, nValue, Params(), CPubKey::RecoverCompact(), SER_GETHASH, strMessageMagic, CBaseChainParams::TESTNET, and vchSig.
◆ Relay()
void CSporkMessage::Relay | ( | CConnman & | connman | ) |
Relay is used to send this spork message to other peers.
Definition at line 425 of file spork.cpp.
References GetHash(), MSG_SPORK, and CConnman::RelayInv().
◆ SerializationOp()
|
inline |
◆ Sign()
bool CSporkMessage::Sign | ( | const CKey & | key | ) |
Sign will sign the spork message with the given key.
Definition at line 339 of file spork.cpp.
References CPubKey::GetID(), CKey::GetPubKey(), GetSignatureHash(), CKey::IsValid(), LogPrintf, nSporkID, nTimeSigned, nValue, Params(), CHashSigner::SignHash(), CMessageSigner::SignMessage(), CBaseChainParams::TESTNET, vchSig, CHashSigner::VerifyHash(), and CMessageSigner::VerifyMessage().
Member Data Documentation
◆ ADD_SERIALIZE_METHODS
◆ nSporkID
SporkId CSporkMessage::nSporkID |
Definition at line 81 of file spork.h.
Referenced by CheckSignature(), GetSignatureHash(), GetSignerKeyID(), SerializationOp(), and Sign().
◆ nTimeSigned
int64_t CSporkMessage::nTimeSigned |
Definition at line 83 of file spork.h.
Referenced by CheckSignature(), GetSignatureHash(), GetSignerKeyID(), SerializationOp(), and Sign().
◆ nValue
int64_t CSporkMessage::nValue |
Definition at line 82 of file spork.h.
Referenced by CheckSignature(), GetSignatureHash(), GetSignerKeyID(), SerializationOp(), and Sign().
◆ vchSig
|
private |
Definition at line 78 of file spork.h.
Referenced by CheckSignature(), GetSignerKeyID(), SerializationOp(), and Sign().
The documentation for this class was generated from the following files: