Serialize the block header in CBlockHeader::GetHash() (#2531)
* Serialize the block header in CBlockHeader::GetHash() * Switch from CDataStream to CVectorWriter Co-Authored-By: solardiz <solar@openwall.com>
This commit is contained in:
parent
5185dd5b73
commit
cbd0303529
@ -397,6 +397,7 @@ libdash_consensus_a_SOURCES = \
|
|||||||
script/script_error.cpp \
|
script/script_error.cpp \
|
||||||
script/script_error.h \
|
script/script_error.h \
|
||||||
serialize.h \
|
serialize.h \
|
||||||
|
streams.h \
|
||||||
tinyformat.h \
|
tinyformat.h \
|
||||||
uint256.cpp \
|
uint256.cpp \
|
||||||
uint256.h \
|
uint256.h \
|
||||||
|
@ -6,13 +6,17 @@
|
|||||||
#include "primitives/block.h"
|
#include "primitives/block.h"
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
#include "streams.h"
|
||||||
#include "tinyformat.h"
|
#include "tinyformat.h"
|
||||||
#include "utilstrencodings.h"
|
#include "utilstrencodings.h"
|
||||||
#include "crypto/common.h"
|
#include "crypto/common.h"
|
||||||
|
|
||||||
uint256 CBlockHeader::GetHash() const
|
uint256 CBlockHeader::GetHash() const
|
||||||
{
|
{
|
||||||
return HashX11(BEGIN(nVersion), END(nNonce));
|
std::vector<unsigned char> vch(80);
|
||||||
|
CVectorWriter ss(SER_NETWORK, PROTOCOL_VERSION, vch, 0);
|
||||||
|
ss << *this;
|
||||||
|
return HashX11((const char *)vch.data(), (const char *)vch.data() + vch.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CBlock::ToString() const
|
std::string CBlock::ToString() const
|
||||||
|
Loading…
Reference in New Issue
Block a user