Safer calcscore implementation
This commit is contained in:
parent
c137a204fb
commit
9e65749ff6
@ -159,8 +159,14 @@ uint256 CMasternode::CalculateScore(int mod, int64_t nBlockHeight)
|
|||||||
|
|
||||||
if(!GetBlockHash(hash, nBlockHeight)) return 0;
|
if(!GetBlockHash(hash, nBlockHeight)) return 0;
|
||||||
|
|
||||||
uint256 hash2 = Hash(BEGIN(hash), END(hash));
|
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
|
||||||
uint256 hash3 = Hash(BEGIN(hash), END(hash), BEGIN(aux), END(aux));
|
ss << hash;
|
||||||
|
uint256 hash2 = ss.GetHash();
|
||||||
|
|
||||||
|
CHashWriter ss2(SER_GETHASH, PROTOCOL_VERSION);
|
||||||
|
ss2 << hash;
|
||||||
|
ss2 << aux;
|
||||||
|
uint256 hash3 = ss2.GetHash();
|
||||||
|
|
||||||
uint256 r = (hash3 > hash2 ? hash3 - hash2 : hash2 - hash3);
|
uint256 r = (hash3 > hash2 ? hash3 - hash2 : hash2 - hash3);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user