From a9500495412f2a4297698b1316f2fc8a569d42ff Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Thu, 5 Feb 2015 16:26:32 -0700 Subject: [PATCH] New improved masternode calculation --- src/main.cpp | 1 + src/masternode.cpp | 20 ++++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 38a1d0857e..9e5de867fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3112,6 +3112,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl return false; } */ + // Check for duplicate uint256 hash = pblock->GetHash(); if (mapBlockIndex.count(hash)) diff --git a/src/masternode.cpp b/src/masternode.cpp index 55e8dcd50a..6c7df96287 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -546,15 +546,11 @@ uint256 CMasterNode::CalculateScore(int mod, int64_t nBlockHeight) if(chainActive.Tip() == NULL) return 0; uint256 hash = 0; - int64_t aux = 0; + uint256 aux = vin.prevout.hash; if(!GetBlockHash(hash, nBlockHeight)) return 0; - - //copy some of the blocks hash into what we'll hash for this calculation - //this will add some randomness to our results - memcpy(&hash+(nBlockHeight%192), &aux, 64); - - uint256 hash2 = HashX11(BEGIN(hash), END(aux)); + uint256 hash2 = HashX11(BEGIN(hash), END(hash)); + uint256 hash3 = HashX11(BEGIN(hash), END(aux)); // we'll make a 4 dimensional point in space // the closest masternode to that point wins @@ -571,11 +567,11 @@ uint256 CMasterNode::CalculateScore(int mod, int64_t nBlockHeight) memcpy(&i3, &a3, 1); memcpy(&i4, &a4, 1); - //split up our mn hash - uint64_t b1 = vin.prevout.hash.Get64(0); - uint64_t b2 = vin.prevout.hash.Get64(1); - uint64_t b3 = vin.prevout.hash.Get64(2); - uint64_t b4 = vin.prevout.hash.Get64(3); + //split up our mn-hash+aux into 4 + uint64_t b1 = hash3.Get64(0); + uint64_t b2 = hash3.Get64(1); + uint64_t b3 = hash3.Get64(2); + uint64_t b4 = hash3.Get64(3); //move mn hash around b1 <<= (i1 % 64);