]> Git Repo - VerusCoin.git/blobdiff - src/primitives/block.cpp
Implementation of VerusHash CPU-friendly hash algorithm, parameters to enable it...
[VerusCoin.git] / src / primitives / block.cpp
index c2300c82a0b1ba819ead33aba547f87d914cdcdb..58164ad8a37126e9ba9580e65cc62676ebb96c47 100644 (file)
 #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
This page took 0.021112 seconds and 4 git commands to generate.