Finish up new POS difficulty calc
This commit is contained in:
@@ -250,7 +250,7 @@ void *chainparams_commandline(void *ptr)
|
|||||||
mainParams.consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
|
mainParams.consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
|
||||||
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
|
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
|
||||||
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
|
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
|
||||||
mainParams.consensus.nLwmaPOSAjustedWeight = 45000;
|
mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkpointData = //(Checkpoints::CCheckpointData)
|
checkpointData = //(Checkpoints::CCheckpointData)
|
||||||
|
|||||||
14
src/pow.cpp
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
|
// Find the first block in the averaging interval as we total the linearly weighted average
|
||||||
// of POS solve times
|
// of POS solve times
|
||||||
const CBlockIndex* pindexFirst = pindexLast;
|
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
|
// 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
|
// 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;
|
pindexFirst = pindexLast;
|
||||||
|
std::vector<solveSequence> idx;
|
||||||
idx.resize(N);
|
idx.resize(N);
|
||||||
|
|
||||||
for (int i = N - 1; i >= 0; i--)
|
for (int i = N - 1; i >= 0; i--)
|
||||||
@@ -237,19 +237,11 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
|||||||
idx[i].nBits = nBits;
|
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,
|
// 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
|
// 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++)
|
for (int j = i; j < N; j++)
|
||||||
{
|
{
|
||||||
if (idx[j].consecutive == true)
|
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;
|
idx[j].solveTime = st;
|
||||||
if ((j - i) >= VERUS_MAX_CONSECUTIVE_POS)
|
if ((j - i) >= VERUS_MAX_CONSECUTIVE_POS)
|
||||||
{
|
{
|
||||||
@@ -257,6 +249,8 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
|||||||
nextTarget.SetCompact(0);
|
nextTarget.SetCompact(0);
|
||||||
return nextTarget.GetCompact();
|
return nextTarget.GetCompact();
|
||||||
}
|
}
|
||||||
|
st >>= 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user