veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
altintegration::BtcBlock Struct Reference

Bitcoin block. More...

Detailed Description

Definition at line 41 of file btcblock.hpp.

#include <btcblock.hpp>

+ Inheritance diagram for altintegration::BtcBlock:
+ Collaboration diagram for altintegration::BtcBlock:

Public Types

using hash_t = uint256
 
using prev_hash_t = uint256
 
using height_t = int32_t
 
using nonce_t = uint32_t
 
using merkle_t = uint256
 
using addon_t = StoredBtcBlockAddon::addon_t
 
using stored_addon_t = StoredBtcBlockAddon
 

Public Member Functions

 BtcBlock (int32_t version, uint256 previousBlock, uint256 merkleRoot, uint32_t timestamp, uint32_t bits, uint32_t nonce)
 
void toRaw (WriteStream &stream) const
 Convert BtcBlock to data stream using BtcBlock basic byte format. More...
 
void toVbkEncoding (WriteStream &stream) const
 Convert BtcBlock to data stream using BtcBlock VBK byte format. More...
 
size_t estimateSize () const
 
hash_t calculateHash () const
 
const hash_tgetHash () const
 Calculate the hash of the btc block. More...
 
std::string toPrettyString () const
 
int32_t getVersion () const
 
uint256 getPreviousBlock () const
 
uint256 getMerkleRoot () const
 
uint32_t getNonce () const
 
uint32_t getTimestamp () const
 
uint32_t getDifficulty () const
 
void setVersion (int32_t v)
 
void setPreviousBlock (const uint256 &prev)
 
void setMerkleRoot (const uint256 &mr)
 
void setDifficulty (uint32_t bits)
 
void setNonce (uint32_t nnc)
 
void setTimestamp (uint32_t ts)
 

Static Public Member Functions

static const std::string & name ()
 

Protected Member Functions

void invalidateHash () const
 

Protected Attributes

int32_t version = 0
 
uint256 previousBlock {}
 
uint256 merkleRoot {}
 
uint32_t timestamp = 0
 
uint32_t bits = 0
 
uint32_t nonce = 0
 
hash_t hash_
 

Static Protected Attributes

static const std::string _name
 

Friends

bool operator== (const BtcBlock &a, const BtcBlock &b)
 
bool operator!= (const BtcBlock &a, const BtcBlock &b)
 
bool DeserializeFromRaw (ReadStream &stream, BtcBlock &block, ValidationState &state, const BtcBlock::hash_t &precalculatedHash)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool DeserializeFromVbkEncoding (ReadStream &stream, BtcBlock &block, ValidationState &state, const BtcBlock::hash_t &precalculatedHash)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Member Typedef Documentation

◆ addon_t

using altintegration::BtcBlock::addon_t = StoredBtcBlockAddon::addon_t

Definition at line 47 of file btcblock.hpp.

◆ hash_t

Definition at line 42 of file btcblock.hpp.

◆ height_t

using altintegration::BtcBlock::height_t = int32_t

Definition at line 44 of file btcblock.hpp.

◆ merkle_t

Definition at line 46 of file btcblock.hpp.

◆ nonce_t

using altintegration::BtcBlock::nonce_t = uint32_t

Definition at line 45 of file btcblock.hpp.

◆ prev_hash_t

Definition at line 43 of file btcblock.hpp.

◆ stored_addon_t

using altintegration::BtcBlock::stored_addon_t = StoredBtcBlockAddon

Definition at line 48 of file btcblock.hpp.

Member Function Documentation

◆ getDifficulty()

uint32_t altintegration::BtcBlock::getDifficulty ( ) const
inline

Definition at line 104 of file btcblock.hpp.

104{ return bits; }

◆ getHash()

const hash_t & altintegration::BtcBlock::getHash ( ) const
Returns
hash block hash

◆ getMerkleRoot()

uint256 altintegration::BtcBlock::getMerkleRoot ( ) const
inline

Definition at line 101 of file btcblock.hpp.

101{ return merkleRoot; }

◆ getNonce()

uint32_t altintegration::BtcBlock::getNonce ( ) const
inline

Definition at line 102 of file btcblock.hpp.

102{ return nonce; }

◆ getPreviousBlock()

uint256 altintegration::BtcBlock::getPreviousBlock ( ) const
inline

Definition at line 100 of file btcblock.hpp.

100{ return previousBlock; }

◆ getTimestamp()

uint32_t altintegration::BtcBlock::getTimestamp ( ) const
inline

Definition at line 103 of file btcblock.hpp.

103{ return timestamp; }

◆ getVersion()

int32_t altintegration::BtcBlock::getVersion ( ) const
inline

Definition at line 99 of file btcblock.hpp.

99{ return version; }

◆ invalidateHash()

void altintegration::BtcBlock::invalidateHash ( ) const
inlineprotected

Definition at line 116 of file btcblock.hpp.

116{ hash_.fill(0); }

◆ name()

static const std::string & altintegration::BtcBlock::name ( )
inlinestatic

Definition at line 95 of file btcblock.hpp.

95{ return _name; }

◆ toRaw()

void altintegration::BtcBlock::toRaw ( WriteStream stream) const
Parameters
streamdata stream to write into

◆ toVbkEncoding()

void altintegration::BtcBlock::toVbkEncoding ( WriteStream stream) const
Parameters
streamdata stream to write into

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const BtcBlock a,
const BtcBlock b 
)
friend

Definition at line 83 of file btcblock.hpp.

83 {
84 return !(a == b);
85 }

◆ operator==

bool operator== ( const BtcBlock a,
const BtcBlock b 
)
friend

Definition at line 72 of file btcblock.hpp.

72 {
73 // clang-format off
74 return a.bits == b.bits &&
75 a.version == b.version &&
76 a.timestamp == b.timestamp &&
77 a.nonce == b.nonce &&
78 a.merkleRoot == b.merkleRoot &&
79 a.previousBlock == b.previousBlock;
80 // clang-format on
81 }

Member Data Documentation

◆ _name

const std::string altintegration::BtcBlock::_name
staticprotected

Definition at line 114 of file btcblock.hpp.

◆ bits

uint32_t altintegration::BtcBlock::bits = 0
protected

Definition at line 122 of file btcblock.hpp.

◆ hash_

hash_t altintegration::BtcBlock::hash_
mutableprotected

Definition at line 125 of file btcblock.hpp.

◆ merkleRoot

uint256 altintegration::BtcBlock::merkleRoot {}
protected

Definition at line 120 of file btcblock.hpp.

◆ nonce

uint32_t altintegration::BtcBlock::nonce = 0
protected

Definition at line 123 of file btcblock.hpp.

◆ previousBlock

uint256 altintegration::BtcBlock::previousBlock {}
protected

Definition at line 119 of file btcblock.hpp.

◆ timestamp

uint32_t altintegration::BtcBlock::timestamp = 0
protected

Definition at line 121 of file btcblock.hpp.

◆ version

int32_t altintegration::BtcBlock::version = 0
protected

Definition at line 118 of file btcblock.hpp.


The documentation for this struct was generated from the following file: