From 503bd93fa8784cd8ca1019944a4705853cad9f38 Mon Sep 17 00:00:00 2001 From: Michael Toutonghi Date: Thu, 19 Jul 2018 01:02:54 -0700 Subject: [PATCH] Differentiate raw POSHash from full one adjusted by vout value --- src/primitives/block.cpp | 7 ++++--- src/primitives/block.h | 2 +- src/primitives/nonce.cpp | 4 ++-- src/primitives/nonce.h | 3 +-- src/primitives/transaction.h | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index dbb477252..39d338959 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -46,8 +46,9 @@ void CBlockHeader::SetVerusHash() } // returns false if unable to fast calculate the VerusPOSHash from the header. it can still be calculated from the block -// in that case -bool CBlockHeader::GetVerusPOSHash(uint256 &value, int32_t nHeight) const +// in that case. the only difference between this and the POS hash for the contest is that it is not divided by the value out +// this is used as a source of entropy +bool CBlockHeader::GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const { // if below the required height or no storage space in the solution, we can't get // a cached txid value to calculate the POSHash from the header @@ -78,7 +79,7 @@ uint256 CBlockHeader::GetVerusEntropyHash(int32_t height) const { uint256 retVal; // if we qualify as PoW, use PoW hash, regardless of PoS state - if (GetVerusPOSHash(retVal, height)) + if (GetRawVerusPOSHash(retVal, height)) { // POS hash return retVal; diff --git a/src/primitives/block.h b/src/primitives/block.h index cf81a213b..06e26f4c5 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -85,7 +85,7 @@ public: uint256 GetVerusHash() const; static void SetVerusHash(); - bool GetVerusPOSHash(uint256 &value, int32_t nHeight) const; + bool GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const; uint256 GetVerusEntropyHash(int32_t nHeight) const; uint256 GetVerusV2Hash() const; diff --git a/src/primitives/nonce.cpp b/src/primitives/nonce.cpp index 491146968..e7ad618ee 100644 --- a/src/primitives/nonce.cpp +++ b/src/primitives/nonce.cpp @@ -10,7 +10,7 @@ extern char ASSETCHAINS_SYMBOL[65]; bool CPOSNonce::NewPOSActive(int32_t height) { - if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) || (height < (96480 + 100))) + if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < (96480 + 100))) return false; else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < (1000 + 100))) return false; @@ -20,7 +20,7 @@ bool CPOSNonce::NewPOSActive(int32_t height) bool CPOSNonce::NewNonceActive(int32_t height) { - if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) || (height < 96480)) + if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < 96480)) return false; else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < 1000)) return false; diff --git a/src/primitives/nonce.h b/src/primitives/nonce.h index f92c983e5..97863e528 100644 --- a/src/primitives/nonce.h +++ b/src/primitives/nonce.h @@ -11,8 +11,7 @@ /** For POS blocks, the nNonce of a block header holds the entropy source for the POS contest - * in the latest VerusHash protocol, implemented at block below - * + * in the latest VerusHash protocol * */ class CPOSNonce : public uint256 { diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 8043fe5a5..852aa4181 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -487,7 +487,7 @@ public: { hashWriter << *pNonce; hashWriter << height; - return hashWriter.GetHash(); + return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value); } else { @@ -495,7 +495,7 @@ public: hashWriter << height; hashWriter << txid; hashWriter << voutNum; - return hashWriter.GetHash(); + return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value); } } @@ -507,7 +507,7 @@ public: if (voutNum >= vout.size()) return uint256S("ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); - return ArithToUint256(UintToArith256(_GetVerusPOSHash(pNonce, txid, voutNum, height, pastHash, (uint64_t)vout[voutNum].nValue)) / vout[voutNum].nValue); + return _GetVerusPOSHash(pNonce, txid, voutNum, height, pastHash, (uint64_t)vout[voutNum].nValue); } std::string ToString() const;