Differentiate raw POSHash from full one adjusted by vout value

This commit is contained in:
Michael Toutonghi
2018-07-19 01:02:54 -07:00
parent c5325a3256
commit 503bd93fa8
5 changed files with 11 additions and 11 deletions

View File

@@ -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 // returns false if unable to fast calculate the VerusPOSHash from the header. it can still be calculated from the block
// in that case // 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
bool CBlockHeader::GetVerusPOSHash(uint256 &value, int32_t nHeight) const // 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 // 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 // a cached txid value to calculate the POSHash from the header
@@ -78,7 +79,7 @@ uint256 CBlockHeader::GetVerusEntropyHash(int32_t height) const
{ {
uint256 retVal; uint256 retVal;
// if we qualify as PoW, use PoW hash, regardless of PoS state // if we qualify as PoW, use PoW hash, regardless of PoS state
if (GetVerusPOSHash(retVal, height)) if (GetRawVerusPOSHash(retVal, height))
{ {
// POS hash // POS hash
return retVal; return retVal;

View File

@@ -85,7 +85,7 @@ public:
uint256 GetVerusHash() const; uint256 GetVerusHash() const;
static void SetVerusHash(); 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 GetVerusEntropyHash(int32_t nHeight) const;
uint256 GetVerusV2Hash() const; uint256 GetVerusV2Hash() const;

View File

@@ -10,7 +10,7 @@ extern char ASSETCHAINS_SYMBOL[65];
bool CPOSNonce::NewPOSActive(int32_t height) 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; return false;
else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < (1000 + 100))) else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < (1000 + 100)))
return false; return false;
@@ -20,7 +20,7 @@ bool CPOSNonce::NewPOSActive(int32_t height)
bool CPOSNonce::NewNonceActive(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; return false;
else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < 1000)) else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < 1000))
return false; return false;

View File

@@ -11,8 +11,7 @@
/** For POS blocks, the nNonce of a block header holds the entropy source for the POS contest /** 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 class CPOSNonce : public uint256
{ {

View File

@@ -487,7 +487,7 @@ public:
{ {
hashWriter << *pNonce; hashWriter << *pNonce;
hashWriter << height; hashWriter << height;
return hashWriter.GetHash(); return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value);
} }
else else
{ {
@@ -495,7 +495,7 @@ public:
hashWriter << height; hashWriter << height;
hashWriter << txid; hashWriter << txid;
hashWriter << voutNum; hashWriter << voutNum;
return hashWriter.GetHash(); return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value);
} }
} }
@@ -507,7 +507,7 @@ public:
if (voutNum >= vout.size()) if (voutNum >= vout.size())
return uint256S("ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); 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; std::string ToString() const;