]> Git Repo - VerusCoin.git/commitdiff
Fix new nonce issue
authorMichael Toutonghi <[email protected]>
Sat, 21 Jul 2018 03:57:28 +0000 (20:57 -0700)
committerMichael Toutonghi <[email protected]>
Sat, 21 Jul 2018 03:57:28 +0000 (20:57 -0700)
src/hash.h
src/primitives/nonce.cpp

index 537ba3dcb985f036d3d09f05b013bdad85ab28e8..d288af3053e5aa5e33530e0a3b85f01be073510d 100644 (file)
@@ -204,6 +204,7 @@ public:
     int nVersion;
 
     CVerusHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn), state() { }
+    void Reset() { state.Reset(); }
 
     CVerusHashWriter& write(const char *pch, size_t size) {
         state.Write((const unsigned char*)pch, size);
@@ -239,6 +240,7 @@ public:
     int nVersion;
 
     CVerusHashV2Writer(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn), state() {}
+    void Reset() { state.Reset(); }
 
     CVerusHashV2Writer& write(const char *pch, size_t size) {
         state.Write((const unsigned char*)pch, size);
index 58970a80fc459599820bddd26e4cbc0fb89a0df7..6ff258174376798a703f8a2313e3ad0b574e04fc 100644 (file)
@@ -46,10 +46,10 @@ void CPOSNonce::SetPOSEntropy(const uint256 &pastHash, uint256 txid, int32_t vou
 
     // printf("before %s\n", ArithToUint256(arNonce).GetHex().c_str());
 
-    CVerusHashWriter newWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
-    newWriter << ArithToUint256(arNonce);
+    hashWriter.Reset();
+    hashWriter << ArithToUint256(arNonce);
 
-    *this = CPOSNonce(ArithToUint256((UintToArith256(newWriter.GetHash()) << 128) | arNonce));
+    *this = CPOSNonce(ArithToUint256((UintToArith256(hashWriter.GetHash()) << 128) | arNonce));
 
     // printf("after  %s\n", this->GetHex().c_str());
 }
@@ -67,7 +67,7 @@ bool CPOSNonce::CheckPOSEntropy(const uint256 &pastHash, uint256 txid, int32_t v
     arith_uint256 arNonce = (UintToArith256(*this) & posDiffMask) |
         (UintToArith256(hashWriter.GetHash()) & entropyMask);
 
-    hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
+    hashWriter.Reset();
     hashWriter << ArithToUint256(arNonce);
 
     return UintToArith256(*this) == (UintToArith256(hashWriter.GetHash()) << 128 | arNonce);
This page took 0.029654 seconds and 4 git commands to generate.