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:
miketout
2018-04-27 00:34:50 -07:00
parent a1af306f81
commit 42181656c2
20 changed files with 1197 additions and 19 deletions

View File

@@ -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