Undo dev changes

This commit is contained in:
myriadcoin
2014-12-07 12:42:52 +02:00
parent 422b250b84
commit 321b2957dd
2 changed files with 1 additions and 71 deletions
-35
View File
@@ -81,36 +81,6 @@ namespace {
{
bool operator()(CBlockIndex *pa, CBlockIndex *pb)
{
if ( (pa->nHeight >= nBlockAlgoNormalisedWorkStart2) ||
(pb->nHeight >= nBlockAlgoNormalisedWorkStart2) )
{
// First sort by most work per algo, ...
int aWins = 0, bWins = 0;
for (int i = 0; i < NUM_ALGOS; i++)
{
if (pa->nAlgoWork[i] > pb->nAlgoWork[i]) aWins++;
if (pa->nAlgoWork[i] < pb->nAlgoWork[i]) bWins++;
}
if (aWins > bWins) return false;
if (aWins < bWins) return true;
// ... then by number of blocks ...
if (pa->nHeight > pb->nHeight) return false;
if (pa->nHeight < pb->nHeight) return true;
// ... then by earliest time received, ...
if (pa->nSequenceId < pb->nSequenceId) return false;
if (pa->nSequenceId > pb->nSequenceId) return true;
// Use pointer address as tie breaker (should only happen with blocks
// loaded from disk, as those all have id 0).
if (pa < pb) return false;
if (pa > pb) return true;
// Identical blocks.
return false;
}
// First sort by most total work, ...
if (pa->nChainWork > pb->nChainWork) return false;
if (pa->nChainWork < pb->nChainWork) return true;
@@ -2353,11 +2323,6 @@ bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos
}
pindexNew->nTx = block.vtx.size();
pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + pindexNew->GetBlockWorkAdjusted().getuint256();
for (int i = 0; i < NUM_ALGOS; i++)
{
pindexNew->nAlgoWork[i] = (pindexNew->pprev ? pindexNew->pprev->nAlgoWork[i] : 0) +
(i == pindexNew->GetAlgo() ? pindexNew->GetBlockWork().getuint256() : 0);
}
pindexNew->nChainTx = (pindexNew->pprev ? pindexNew->pprev->nChainTx : 0) + pindexNew->nTx;
pindexNew->nFile = pos.nFile;
pindexNew->nDataPos = pos.nPos;
+1 -36
View File
@@ -689,7 +689,6 @@ enum BlockStatus {
const int64_t nBlockAlgoWorkWeightStart = 142000; // block where algo work weighting starts
const int64_t nBlockAlgoNormalisedWorkStart = 740000; // block where algo combined weight starts
const int64_t nBlockAlgoNormalisedWorkStart2 = 99990000; // block where algo combined weight starts with decay
const int64_t nBlockSequentialAlgoRuleStart = 740000; // block where sequential algo rule starts
const int64_t nBlockSequentialAlgoRuleStart2 = 766000; // block where sequential algo rule starts
const int nBlockSequentialAlgoMaxCount = 6; // maximum sequential blocks of same algo
@@ -727,8 +726,6 @@ public:
// (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
uint256 nChainWork;
uint256 nAlgoWork[NUM_ALGOS];
// Number of transactions in this block.
// Note: in a potential headers-first mode, this number cannot be relied upon
unsigned int nTx;
@@ -758,8 +755,6 @@ public:
nDataPos = 0;
nUndoPos = 0;
nChainWork = 0;
for (int i = 0; i < NUM_ALGOS; i++)
nAlgoWork[i] = 0;
nTx = 0;
nChainTx = 0;
nStatus = 0;
@@ -781,8 +776,6 @@ public:
nDataPos = 0;
nUndoPos = 0;
nChainWork = 0;
for (int i = 0; i < NUM_ALGOS; i++)
nAlgoWork[i] = 0;
nTx = 0;
nChainTx = 0;
nStatus = 0;
@@ -852,31 +845,6 @@ public:
return Params().ProofOfWorkLimit(algo);
}
CBigNum GetPrevWorkForAlgoWithDecay(int algo) const
{
int nDistance = 0;
CBlockIndex* pindex = this->pprev;
while (pindex)
{
if (nDistance > 32)
{
return Params().ProofOfWorkLimit(algo);
}
if (pindex->GetAlgo() == algo)
{
CBigNum nWork = pindex->GetBlockWork();
nWork *= (32 - nDistance);
nWork /= 32;
if (nWork < Params().ProofOfWorkLimit(algo))
nWork = Params().ProofOfWorkLimit(algo);
return nWork;
}
pindex = pindex->pprev;
nDistance++;
}
return Params().ProofOfWorkLimit(algo);
}
CBigNum GetBlockWork() const
{
CBigNum bnTarget;
@@ -928,10 +896,7 @@ public:
{
if (algo != nAlgo)
{
if (nHeight >= nBlockAlgoNormalisedWorkStart2)
nBlockWork += GetPrevWorkForAlgoWithDecay(algo);
else
nBlockWork += GetPrevWorkForAlgo(algo);
nBlockWork += GetPrevWorkForAlgo(algo);
}
}
bnRes = nBlockWork / NUM_ALGOS;