mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-17 05:41:34 +02:00
Postpone algo comparison changes
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
|
||||
define(_CLIENT_VERSION_MAJOR, 0)
|
||||
define(_CLIENT_VERSION_MINOR, 9)
|
||||
define(_CLIENT_VERSION_REVISION, 2)
|
||||
define(_CLIENT_VERSION_BUILD, 8)
|
||||
define(_CLIENT_VERSION_BUILD, 9)
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2014)
|
||||
AC_INIT([Myriadcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitcoin.org],[myriadcoin])
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 9
|
||||
#define CLIENT_VERSION_REVISION 2
|
||||
#define CLIENT_VERSION_BUILD 8
|
||||
#define CLIENT_VERSION_BUILD 9
|
||||
|
||||
// Set to true for release, false for prerelease or test build
|
||||
#define CLIENT_VERSION_IS_RELEASE true
|
||||
|
||||
+6
-68
@@ -99,42 +99,9 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
struct CBlockIndexWorkComparator2
|
||||
{
|
||||
bool operator()(CBlockIndex *pa, CBlockIndex *pb)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
|
||||
CBlockIndex *pindexBestInvalid;
|
||||
// may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
|
||||
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
|
||||
set<CBlockIndex*, CBlockIndexWorkComparator2> setBlockIndexValid2; // interim measure to transition between comparator1 and comparator2
|
||||
|
||||
CCriticalSection cs_LastBlockFile;
|
||||
CBlockFileInfo infoLastBlockFile;
|
||||
@@ -1656,7 +1623,6 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state
|
||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||
pblocktree->WriteBlockIndex(CDiskBlockIndex(pindex));
|
||||
setBlockIndexValid.erase(pindex);
|
||||
setBlockIndexValid2.erase(pindex);
|
||||
InvalidChainFound(pindex);
|
||||
}
|
||||
}
|
||||
@@ -2236,36 +2202,21 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew) {
|
||||
void static FindMostWorkChain()
|
||||
{
|
||||
|
||||
int CompareVersion = 1;
|
||||
if (chainActive.Tip() && (chainActive.Tip()->nHeight >= nBlockAlgoCountWorkStart))
|
||||
CompareVersion = 2;
|
||||
|
||||
CBlockIndex *pindexNew = NULL;
|
||||
|
||||
// In case the current best is invalid, do not consider it.
|
||||
while (chainMostWork.Tip() && (chainMostWork.Tip()->nStatus & BLOCK_FAILED_MASK)) {
|
||||
setBlockIndexValid.erase(chainMostWork.Tip());
|
||||
setBlockIndexValid2.erase(chainMostWork.Tip());
|
||||
chainMostWork.SetTip(chainMostWork.Tip()->pprev);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// Find the best candidate header.
|
||||
if (CompareVersion == 1)
|
||||
{
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator>::reverse_iterator it = setBlockIndexValid.rbegin();
|
||||
if (it == setBlockIndexValid.rend())
|
||||
return;
|
||||
pindexNew = *it;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator2>::reverse_iterator it = setBlockIndexValid2.rbegin();
|
||||
if (it == setBlockIndexValid2.rend())
|
||||
return;
|
||||
pindexNew = *it;
|
||||
}
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator>::reverse_iterator it = setBlockIndexValid.rbegin();
|
||||
if (it == setBlockIndexValid.rend())
|
||||
return;
|
||||
pindexNew = *it;
|
||||
|
||||
// Check whether all blocks on the path between the currently active chain and the candidate are valid.
|
||||
// Just going until the active chain is an optimization, as we know all blocks in it are valid already.
|
||||
@@ -2279,7 +2230,6 @@ void static FindMostWorkChain()
|
||||
while (pindexTest != pindexFailed) {
|
||||
pindexFailed->nStatus |= BLOCK_FAILED_CHILD;
|
||||
setBlockIndexValid.erase(pindexFailed);
|
||||
setBlockIndexValid2.erase(pindexFailed);
|
||||
pindexFailed = pindexFailed->pprev;
|
||||
}
|
||||
fInvalidAncestor = true;
|
||||
@@ -2293,17 +2243,8 @@ void static FindMostWorkChain()
|
||||
break;
|
||||
} while(true);
|
||||
|
||||
// Check whether it's actually an improvement.
|
||||
if (CompareVersion == 1)
|
||||
{
|
||||
if (chainMostWork.Tip() && !CBlockIndexWorkComparator()(chainMostWork.Tip(), pindexNew))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chainMostWork.Tip() && !CBlockIndexWorkComparator2()(chainMostWork.Tip(), pindexNew))
|
||||
return;
|
||||
}
|
||||
if (chainMostWork.Tip() && !CBlockIndexWorkComparator()(chainMostWork.Tip(), pindexNew))
|
||||
return;
|
||||
|
||||
// We have a new best.
|
||||
chainMostWork.SetTip(pindexNew);
|
||||
@@ -2393,7 +2334,6 @@ bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos
|
||||
pindexNew->nUndoPos = 0;
|
||||
pindexNew->nStatus = BLOCK_VALID_TRANSACTIONS | BLOCK_HAVE_DATA;
|
||||
setBlockIndexValid.insert(pindexNew);
|
||||
setBlockIndexValid2.insert(pindexNew);
|
||||
|
||||
if (!pblocktree->WriteBlockIndex(CDiskBlockIndex(pindexNew)))
|
||||
return state.Abort(_("Failed to write block index"));
|
||||
@@ -3100,7 +3040,6 @@ bool static LoadBlockIndexDB()
|
||||
if ((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS && !(pindex->nStatus & BLOCK_FAILED_MASK))
|
||||
{
|
||||
setBlockIndexValid.insert(pindex);
|
||||
setBlockIndexValid2.insert(pindex);
|
||||
}
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK && (!pindexBestInvalid || pindex->nChainWork > pindexBestInvalid->nChainWork))
|
||||
pindexBestInvalid = pindex;
|
||||
@@ -3212,7 +3151,6 @@ void UnloadBlockIndex()
|
||||
{
|
||||
mapBlockIndex.clear();
|
||||
setBlockIndexValid.clear();
|
||||
setBlockIndexValid2.clear();
|
||||
chainActive.SetTip(NULL);
|
||||
pindexBestInvalid = NULL;
|
||||
}
|
||||
|
||||
@@ -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 nBlockAlgoCountWorkStart = 857000; // block where new work comparison starts
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user