Radical hash rate optimization
This commit is contained in:
@@ -27,19 +27,10 @@ uint256 CBlockHeader::GetVerusHash() const
|
||||
return SerializeVerusHash(*this);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetVerusHashPortable() const
|
||||
{
|
||||
if (hashPrevBlock.IsNull())
|
||||
// always use SHA256D for genesis block
|
||||
return SerializeHash(*this);
|
||||
else
|
||||
return SerializeVerusHashPortable(*this);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetVerusMiningHash() const
|
||||
uint256 CBlockHeader::GetVerusV2Hash() const
|
||||
{
|
||||
// no check for genesis block and use the optimized hash
|
||||
return SerializeVerusMiningHash(*this);
|
||||
return SerializeVerusHashV2(*this);
|
||||
}
|
||||
|
||||
void CBlockHeader::SetSHA256DHash()
|
||||
@@ -52,11 +43,6 @@ void CBlockHeader::SetVerusHash()
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetVerusHash;
|
||||
}
|
||||
|
||||
void CBlockHeader::SetVerusHashPortable()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetVerusHashPortable;
|
||||
}
|
||||
|
||||
uint256 CBlock::BuildMerkleTree(bool* fMutated) const
|
||||
{
|
||||
/* WARNING! If you're reading this because you're learning about crypto
|
||||
|
||||
@@ -84,10 +84,7 @@ public:
|
||||
uint256 GetVerusHash() const;
|
||||
static void SetVerusHash();
|
||||
|
||||
uint256 GetVerusHashPortable() const;
|
||||
static void SetVerusHashPortable();
|
||||
|
||||
uint256 GetVerusMiningHash() const;
|
||||
uint256 GetVerusV2Hash() const;
|
||||
|
||||
int64_t GetBlockTime() const
|
||||
{
|
||||
@@ -110,14 +107,14 @@ public:
|
||||
{
|
||||
arith_uint256 arNonce = UintToArith256(nNonce);
|
||||
arith_uint256 tmpNonce = ((arNonce << 128) >> 128);
|
||||
CVerusHashPortableWriter hashWriter = CVerusHashPortableWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
hashWriter << ArithToUint256(tmpNonce);
|
||||
return (nNonce == ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | tmpNonce));
|
||||
}
|
||||
|
||||
void SetVerusPOSTarget(int32_t nBits)
|
||||
{
|
||||
CVerusHashPortableWriter hashWriter = CVerusHashPortableWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
uint256 hash;
|
||||
arith_uint256 tmpNonce;
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ public:
|
||||
// verus hash will be the same for a given txid, output number, block height, and blockhash of 100 blocks past
|
||||
static uint256 _GetVerusPOSHash(const uint256 &txid, int32_t voutNum, int32_t height, const uint256 &pastHash, int64_t value)
|
||||
{
|
||||
CVerusHashPortableWriter hashWriter = CVerusHashPortableWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
hashWriter << ASSETCHAINS_MAGIC;
|
||||
hashWriter << pastHash;
|
||||
|
||||
Reference in New Issue
Block a user