Always set nBits
This commit is contained in:
16
src/pow.cpp
16
src/pow.cpp
@@ -107,7 +107,7 @@ arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTar
|
||||
bnTarget = ct[0] / arith_uint256(K);
|
||||
bnTarget *= arith_uint256(outerK);
|
||||
}
|
||||
}
|
||||
} else fprintf(stderr,"ht.%d no outer trigger %d >= %d\n",height,(ts[0] - ts[W]),(T * numerator)/denominator);
|
||||
return(bnTarget);
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ arith_uint256 RT_CST_RST_target(int32_t height,uint32_t nTime,arith_uint256 bnTa
|
||||
arith_uint256 RT_CST_RST_inner(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past,int32_t outeri)
|
||||
{
|
||||
arith_uint256 bnTargetW,bnTargetwidth,bnTmp; int32_t width = outeri+W;
|
||||
fprintf(stderr,"check inner outeri.%d, width.%d %d vs %d\n",outeri,width,(ts[0] - ts[width]),width*T);
|
||||
if ( (ts[0] - ts[width]) < width*T )
|
||||
{
|
||||
bnTargetW = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W);
|
||||
@@ -293,20 +294,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
bnPrev.SetCompact(pindexFirst->nBits);
|
||||
for (i=0; pindexFirst != 0 && i<(int32_t)(sizeof(ct)/sizeof(*ct)); i++)
|
||||
{
|
||||
if ( height-i-1 >= (int32_t)(sizeof(ct)/sizeof(*ct)) )
|
||||
zflags[i] = (pindexFirst->nBits & 3);
|
||||
/*if ( (pindexFirst->nBits&3) != 0 )
|
||||
{
|
||||
ct[i] = UintToArith256(pindexFirst->GetBlockHash());
|
||||
ct[i] /= arith_uint256((pindexFirst->nBits&3) + 1);
|
||||
} else*/
|
||||
ct[i].SetCompact(pindexFirst->nBits);
|
||||
ts[i] = pindexFirst->nTime;
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
}
|
||||
for (i=0; pindexFirst != 0 && i<(int32_t)(sizeof(ct)/sizeof(*ct))-1; i++)
|
||||
{
|
||||
if ( zflags[i] != 0 )
|
||||
if ( zflags[i] != 0 && height-1-i >= (int32_t)(sizeof(ct)/sizeof(*ct)) )
|
||||
ct[i] = zawy_ctB(ct[i],ts[i] - ts[i+1]);
|
||||
}
|
||||
}
|
||||
@@ -341,9 +336,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
|
||||
bool fNegative,fOverflow; int32_t past,zawyflag = 0; arith_uint256 easy,origtarget,bnAvg {bnTot / params.nPowAveragingWindow};
|
||||
nbits = CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
||||
if ( ASSETCHAINS_ADAPTIVEPOW > 0 && height >= (int32_t)(sizeof(ct)/sizeof(*ct)) )
|
||||
if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
|
||||
{
|
||||
bnTarget = arith_uint256().SetCompact(nbits);
|
||||
if ( height >= (int32_t)(sizeof(ct)/sizeof(*ct)) )
|
||||
{
|
||||
easy.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
if ( pblock != 0 )
|
||||
{
|
||||
@@ -400,6 +397,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
}
|
||||
fprintf(stderr," cmp.%d mult.%d for ht.%d\n",mult>1,(int32_t)mult,height);
|
||||
}
|
||||
}
|
||||
nbits = bnTarget.GetCompact();
|
||||
nbits = (nbits & 0xfffffffc) | zawyflag;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user