Created
June 23, 2021 14:44
-
-
Save andrewkkchan/d1eecff037628ea00ebd8b3f1db75178 to your computer and use it in GitHub Desktop.
BlockHeader of BitCoin Core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CBlockHeader | |
{ | |
public: | |
// header | |
int32_t nVersion; | |
uint256 hashPrevBlock; | |
uint256 hashMerkleRoot; | |
uint32_t nTime; | |
uint32_t nBits; | |
uint32_t nNonce; | |
CBlockHeader() | |
{ | |
SetNull(); | |
} | |
SERIALIZE_METHODS(CBlockHeader, obj) { READWRITE(obj.nVersion, obj.hashPrevBlock, obj.hashMerkleRoot, obj.nTime, obj.nBits, obj.nNonce); } | |
void SetNull() | |
{ | |
nVersion = 0; | |
hashPrevBlock.SetNull(); | |
hashMerkleRoot.SetNull(); | |
nTime = 0; | |
nBits = 0; | |
nNonce = 0; | |
} | |
bool IsNull() const | |
{ | |
return (nBits == 0); | |
} | |
uint256 GetHash() const; | |
int64_t GetBlockTime() const | |
{ | |
return (int64_t)nTime; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment