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.

Definition at line 75 of file spork.h.

Constructor & Destructor Documentation

◆ CSporkMessage() [1/2]

CSporkMessage::CSporkMessage ( SporkId  nSporkID,
int64_t  nValue,
int64_t  nTimeSigned 
)
inline

Definition at line 85 of file spork.h.

◆ CSporkMessage() [2/2]

CSporkMessage::CSporkMessage ( )
inline

Definition at line 91 of file spork.h.

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()

template<typename Stream , typename Operation >
void CSporkMessage::SerializationOp ( Stream &  s,
Operation  ser_action 
)
inline

Definition at line 101 of file spork.h.

References nSporkID, nTimeSigned, nValue, READWRITE, and vchSig.

◆ Sign()

Member Data Documentation

◆ ADD_SERIALIZE_METHODS

CSporkMessage::ADD_SERIALIZE_METHODS

Definition at line 98 of file spork.h.

◆ 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

std::vector<unsigned char> CSporkMessage::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:
Released under the MIT license