Cleanup nonce changes

This commit is contained in:
Michael Toutonghi
2018-07-20 19:57:46 -07:00
parent 503bd93fa8
commit 17d0160a17
10 changed files with 53 additions and 33 deletions

View File

@@ -95,7 +95,7 @@ public:
return (int64_t)nTime;
}
int32_t GetVerusPOSTarget() const
uint32_t GetVerusPOSTarget() const
{
uint32_t nBits = 0;
@@ -112,19 +112,22 @@ public:
return nNonce.IsPOSNonce();
}
void SetVerusPOSTarget(int32_t nBits)
void SetVerusPOSTarget(uint32_t nBits)
{
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
uint256 hash;
arith_uint256 tmpNonce;
arith_uint256 arNonce = UintToArith256(nNonce);
arNonce = ((arNonce >> 32) << 32) | nBits;
tmpNonce = ((arNonce << 128) >> 128);
hashWriter << ArithToUint256(tmpNonce);
// printf("before svpt: %s\n", ArithToUint256(arNonce).GetHex().c_str());
nNonce = ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | tmpNonce);
arNonce = (arNonce & CPOSNonce::entropyMask) | nBits;
// printf("after clear: %s\n", ArithToUint256(arNonce).GetHex().c_str());
hashWriter << ArithToUint256(arNonce);
nNonce = CPOSNonce(ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | arNonce));
// printf(" after svpt: %s\n", nNonce.GetHex().c_str());
}
};