mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-20 06:08:43 +02:00
Security update: work decay
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, 9)
|
||||
define(_CLIENT_VERSION_BUILD, 10)
|
||||
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 9
|
||||
#define CLIENT_VERSION_BUILD 10
|
||||
|
||||
// Set to true for release, false for prerelease or test build
|
||||
#define CLIENT_VERSION_IS_RELEASE true
|
||||
|
||||
+31
-1
@@ -689,6 +689,7 @@ 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 nBlockAlgoNormalisedWorkDecayStart = 866000; // block where weight decay 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
|
||||
@@ -851,6 +852,32 @@ public:
|
||||
return Params().ProofOfWorkLimit(algo);
|
||||
}
|
||||
|
||||
CBigNum GetPrevWorkForAlgoWithDecay(int algo) const
|
||||
{
|
||||
int nDistance = 0;
|
||||
CBigNum nWork;
|
||||
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;
|
||||
@@ -902,7 +929,10 @@ public:
|
||||
{
|
||||
if (algo != nAlgo)
|
||||
{
|
||||
nBlockWork += GetPrevWorkForAlgo(algo);
|
||||
if (nHeight >= nBlockAlgoNormalisedWorkDecayStart)
|
||||
nBlockWork += GetPrevWorkForAlgoWithDecay(algo);
|
||||
else
|
||||
nBlockWork += GetPrevWorkForAlgo(algo);
|
||||
}
|
||||
}
|
||||
bnRes = nBlockWork / NUM_ALGOS;
|
||||
|
||||
Reference in New Issue
Block a user