This commit is contained in:
myriadcoin
2014-11-02 13:14:13 +02:00
parent 6a21f1c45e
commit efcbaca72c
4 changed files with 60 additions and 12 deletions
+1 -1
View File
@@ -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, 5)
define(_CLIENT_VERSION_BUILD, 6)
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
View File
@@ -12,7 +12,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 5
#define CLIENT_VERSION_BUILD 6
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
+57 -10
View File
@@ -1317,25 +1317,72 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
// find previous block with same algo
const CBlockIndex* pindexPrev = GetLastBlockIndexForAlgo(pindexLast, algo);
if (pindexPrev == NULL)
return nProofOfWorkLimit;
// find first block in averaging interval
// Go back by what we want to be nAveragingInterval blocks
const CBlockIndex* pindexFirst = pindexPrev;
for (int i = 0; pindexFirst && i < nAveragingInterval - 1; i++)
const CBlockIndex* pindexFirst = NULL;
if (pindexLast->nHeight >= nBlockTimeWarpPreventStart)
{
pindexFirst = pindexFirst->pprev;
pindexFirst = GetLastBlockIndexForAlgo(pindexFirst, algo);
// find first block in averaging interval
// Go back by what we want to be nAveragingInterval blocks
pindexFirst = pindexPrev;
for (int i = 0; pindexFirst && i < nAveragingInterval - 1; i++)
{
pindexFirst = pindexFirst->pprev;
pindexFirst = GetLastBlockIndexForAlgo(pindexFirst, algo);
}
if (pindexFirst == NULL)
return nProofOfWorkLimit; // not nAveragingInterval blocks of this algo available
// check block before first block for time warp
const CBlockIndex* pindexFirstPrev = pindexFirst->pprev;
if (pindexFirstPrev == NULL)
return nProofOfWorkLimit;
pindexFirstPrev = GetLastBlockIndexForAlgo(pindexFirstPrev, algo);
if (pindexFirstPrev == NULL)
return nProofOfWorkLimit;
// take previous block if block times are out of order
if (pindexFirstPrev->GetBlockTime() > pindexFirst->GetBlockTime())
{
LogPrintf(" First blocks out of order times, swapping: %d %d\n", pindexFirstPrev->GetBlockTime(), pindexFirst->GetBlockTime());
pindexFirst = pindexFirstPrev;
}
}
else
{
// find first block in averaging interval
// Go back by what we want to be nAveragingInterval blocks
pindexFirst = pindexPrev;
for (int i = 0; pindexFirst && i < nAveragingInterval - 1; i++)
{
pindexFirst = pindexFirst->pprev;
pindexFirst = GetLastBlockIndexForAlgo(pindexFirst, algo);
}
if (pindexFirst == NULL)
return nProofOfWorkLimit; // not nAveragingInterval blocks of this algo available
}
if (pindexFirst == NULL)
return nProofOfWorkLimit; // not nAveragingInterval blocks of this algo available
// Limit adjustment step
int64_t nActualTimespan = pindexPrev->GetBlockTime() - pindexFirst->GetBlockTime();
LogPrintf(" nActualTimespan = %d before bounds %d %d\n", nActualTimespan, pindexPrev->GetBlockTime(), pindexFirst->GetBlockTime());
// Time warp mitigation: Don't adjust difficulty if time is negative
if (pindexLast->nHeight >= nBlockTimeWarpPreventStart)
{
if (nActualTimespan < 0)
{
LogPrintf(" nActualTimespan negative %d\n", nActualTimespan);
LogPrintf(" Keeping: %08x %s\n", pindexPrev->nBits, CBigNum().SetCompact(pindexPrev->nBits).getuint256().ToString());
return pindexPrev->nBits;
}
}
if (nActualTimespan < nMinActualTimespan)
nActualTimespan = nMinActualTimespan;
if (nActualTimespan > nMaxActualTimespan)
nActualTimespan = nMaxActualTimespan;
LogPrintf(" nActualTimespan = %d after bounds %d %d\n", nActualTimespan, nMinActualTimespan, nMaxActualTimespan);
// Retarget
CBigNum bnNew;
@@ -1348,8 +1395,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
/// debug print
LogPrintf("GetNextWorkRequired RETARGET\n");
LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", nTargetTimespan, nActualTimespan);
LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString());
LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", nAveragingTargetTimespan, nActualTimespan);
LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexPrev->nBits).getuint256().ToString());
LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString());
return bnNew.GetCompact();
+1
View File
@@ -691,6 +691,7 @@ const int64_t nBlockAlgoWorkWeightStart = 142000; // block where algo work weigh
const int64_t nBlockAlgoNormalisedWorkStart = 740000; // block where algo combined weight starts
const int64_t nBlockSequentialAlgoRuleStart = 740000; // block where sequential algo rule starts
const int nBlockSequentialAlgoMaxCount = 6; // maximum sequential blocks of same algo
const int64_t nBlockTimeWarpPreventStart = 740500; // block where sequential algo rule starts
/** The block chain is a tree shaped structure starting with the
* genesis block at the root, with each block potentially having multiple