Implementation of VerusHash CPU-friendly hash algorithm, parameters to enable it, miner, and all changes required to support it on new asset chains
This commit is contained in:
@@ -10,11 +10,33 @@
|
||||
#include "utilstrencodings.h"
|
||||
#include "crypto/common.h"
|
||||
|
||||
uint256 CBlockHeader::GetHash() const
|
||||
// default hash algorithm for block
|
||||
uint256 (CBlockHeader::*CBlockHeader::hashFunction)() const = &CBlockHeader::GetSHA256DHash;
|
||||
|
||||
uint256 CBlockHeader::GetSHA256DHash() const
|
||||
{
|
||||
return SerializeHash(*this);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetVerusHash() const
|
||||
{
|
||||
if (hashPrevBlock == uint256())
|
||||
// always use SHA256D for genesis block
|
||||
return SerializeHash(*this);
|
||||
else
|
||||
return SerializeVerusHash(*this);
|
||||
}
|
||||
|
||||
void CBlockHeader::SetSHA256DHash()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetSHA256DHash;
|
||||
}
|
||||
|
||||
void CBlockHeader::SetVerusHash()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetVerusHash;
|
||||
}
|
||||
|
||||
uint256 CBlock::BuildMerkleTree(bool* fMutated) const
|
||||
{
|
||||
/* WARNING! If you're reading this because you're learning about crypto
|
||||
|
||||
@@ -23,6 +23,10 @@ public:
|
||||
// header
|
||||
static const size_t HEADER_SIZE=4+32+32+32+4+4+32; // excluding Equihash solution
|
||||
static const int32_t CURRENT_VERSION=4;
|
||||
static uint256 (CBlockHeader::*hashFunction)() const;
|
||||
|
||||
static void SetHashAlgo();
|
||||
|
||||
int32_t nVersion;
|
||||
uint256 hashPrevBlock;
|
||||
uint256 hashMerkleRoot;
|
||||
@@ -69,7 +73,16 @@ public:
|
||||
return (nBits == 0);
|
||||
}
|
||||
|
||||
uint256 GetHash() const;
|
||||
uint256 GetHash() const
|
||||
{
|
||||
return (this->*hashFunction)();
|
||||
}
|
||||
|
||||
uint256 GetSHA256DHash() const;
|
||||
static void SetSHA256DHash();
|
||||
|
||||
uint256 GetVerusHash() const;
|
||||
static void SetVerusHash();
|
||||
|
||||
int64_t GetBlockTime() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user