Browse Source

Finish up new POS difficulty calc

pull/4/head
Michael Toutonghi 6 years ago
parent
commit
3de80992e0
  1. 2
      src/chainparams.cpp
  2. 14
      src/pow.cpp

2
src/chainparams.cpp

@ -250,7 +250,7 @@ void *chainparams_commandline(void *ptr)
mainParams.consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
mainParams.consensus.nLwmaPOSAjustedWeight = 45000;
mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
}
checkpointData = //(Checkpoints::CCheckpointData)

14
src/pow.cpp

@ -181,7 +181,6 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
// Find the first block in the averaging interval as we total the linearly weighted average
// of POS solve times
const CBlockIndex* pindexFirst = pindexLast;
std::vector<solveSequence> idx;
// we need to make sure we have a starting nBits reference, which is either the last POS block, or the default
// if we have had no POS block in the threshold number of blocks, we must return the default, otherwise, we'll now have
@ -203,6 +202,7 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
}
pindexFirst = pindexLast;
std::vector<solveSequence> idx;
idx.resize(N);
for (int i = N - 1; i >= 0; i--)
@ -237,19 +237,11 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
idx[i].nBits = nBits;
// go forward and halve the minimum solve time for all consecutive blocks in this run, to get here, our last block is POS,
// and if there is no POS block in front of it, it gets the normal solve time of one block
uint32_t st = VERUS_BLOCK_POSUNITS << 1;
uint32_t st = VERUS_BLOCK_POSUNITS;
for (int j = i; j < N; j++)
{
if (idx[j].consecutive == true)
{
st >>= 1;
}
else
break;
}
for (int j = i; j < N; j++)
{
if (idx[j].consecutive == true)
idx[j].solveTime = st;
if ((j - i) >= VERUS_MAX_CONSECUTIVE_POS)
{
@ -257,6 +249,8 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
nextTarget.SetCompact(0);
return nextTarget.GetCompact();
}
st >>= 1;
}
else
break;
}

Loading…
Cancel
Save