better calculation for election

This commit is contained in:
Evan 2014-04-03 15:00:59 -07:00
parent 9ea042a12a
commit 2242763cbc
2 changed files with 14 additions and 9 deletions

View File

@ -1581,7 +1581,7 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBl
{
int DiffMode = 1;
if (fTestNet) {
if (pindexLast->nHeight+1 >= 15) { DiffMode = 4; }
if (pindexLast->nHeight+1 >= 430) { DiffMode = 4; }
else if (pindexLast->nHeight+1 >= 5) { DiffMode = 3; }
}
else {
@ -5854,6 +5854,18 @@ void CDarkSendPool::RegisterAsMasterNode()
}
}
uint256 CMasterNode::CalculateScore()
{
if(pindexBest == NULL) return 0;
int nVersion = 1;
uint256 n1 = pindexBest->GetBlockHash();
uint256 n2 = Hash9(BEGIN(nVersion), END(n1));
uint256 n3 = vin.prevout.hash > n2 ? (vin.prevout.hash - n2) : (n2 - vin.prevout.hash);
printf(" -- MasterNode CalculateScore() = %s \n", n3.ToString().c_str());
return n3;
}
void ThreadCheckDarkSendPool()
{

View File

@ -2311,14 +2311,7 @@ public:
newVin = newVin;
}
uint256 CalculateScore()
{
if(pindexBest == NULL) return 0;
uint256 n = vin.prevout.hash > pindexBest->GetBlockHash() ? (vin.prevout.hash - pindexBest->GetBlockHash()) : (pindexBest->GetBlockHash() - vin.prevout.hash);
printf(" -- MasterNode CalculateScore() = %s \n", n.ToString().c_str());
return n;
}
uint256 CalculateScore();
void UpdateLastSeen()
{