Fix
This commit is contained in:
57
src/pow.cpp
57
src/pow.cpp
@@ -346,33 +346,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
if ( zflags[i] != 0 )
|
if ( zflags[i] != 0 )
|
||||||
ct[i] = zawy_ctB(ct[i],ts[i] - ts[i+1]);
|
ct[i] = zawy_ctB(ct[i],ts[i] - ts[i+1]);
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_ADAPTIVEPOW == 1 ) // TSA
|
|
||||||
{
|
|
||||||
arith_uint256 A,B,C;
|
|
||||||
if ( tipdiff < 2 )
|
|
||||||
tipdiff = 2;
|
|
||||||
bnTarget = ct[0] / arith_uint256(K*T);
|
|
||||||
A = bnTarget * arith_uint256(T);
|
|
||||||
B = bnTarget * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff/2)) / arith_uint256(360000);
|
|
||||||
C = bnTarget * arith_uint256(T * zawy_exponential_val360000(tipdiff/2)) / arith_uint256(360000);
|
|
||||||
bnTarget = (A + B - C) * arith_uint256(K*T) / arith_uint256(tipdiff);
|
|
||||||
{
|
|
||||||
int32_t z;
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," ht.%d TSA bnTarget tipdiff.%d\n",height,tipdiff);
|
|
||||||
/*bnTarget = (bnTarget + ct[0] + ct[1] + ct[2]) / arith_uint256(4);
|
|
||||||
{
|
|
||||||
int32_t z;
|
|
||||||
for (z=31; z>=0; z--)
|
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," sma\n");*/
|
|
||||||
//nbits = bnTarget.GetCompact();
|
|
||||||
//nbits = (nbits & 0xfffffffc) | 0;
|
|
||||||
//return(nbits);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pindexFirst = pindexLast;
|
pindexFirst = pindexLast;
|
||||||
for (i = 0; pindexFirst && i < params.nPowAveragingWindow; i++)
|
for (i = 0; pindexFirst && i < params.nPowAveragingWindow; i++)
|
||||||
@@ -407,10 +380,36 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
nbits = CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
nbits = CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
||||||
if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
|
if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_ADAPTIVEPOW != 1 ) // not-TSA
|
bnTarget = arith_uint256().SetCompact(nbits);
|
||||||
bnTarget = arith_uint256().SetCompact(nbits);
|
|
||||||
if ( height > (int32_t)(sizeof(ct)/sizeof(*ct)) )
|
if ( height > (int32_t)(sizeof(ct)/sizeof(*ct)) )
|
||||||
{
|
{
|
||||||
|
if ( ASSETCHAINS_ADAPTIVEPOW == 1 ) // TSA
|
||||||
|
{
|
||||||
|
arith_uint256 A,B,C;
|
||||||
|
if ( tipdiff < 2 )
|
||||||
|
tipdiff = 2;
|
||||||
|
bnTarget = ct[0] / arith_uint256(K*T);
|
||||||
|
A = bnTarget * arith_uint256(T);
|
||||||
|
B = bnTarget * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff/2)) / arith_uint256(360000);
|
||||||
|
C = bnTarget * arith_uint256(T * zawy_exponential_val360000(tipdiff/2)) / arith_uint256(360000);
|
||||||
|
bnTarget = (A + B - C) * arith_uint256(K*T) / arith_uint256(tipdiff);
|
||||||
|
{
|
||||||
|
int32_t z;
|
||||||
|
for (z=31; z>=0; z--)
|
||||||
|
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||||
|
}
|
||||||
|
fprintf(stderr," ht.%d TSA bnTarget tipdiff.%d\n",height,tipdiff);
|
||||||
|
/*bnTarget = (bnTarget + ct[0] + ct[1] + ct[2]) / arith_uint256(4);
|
||||||
|
{
|
||||||
|
int32_t z;
|
||||||
|
for (z=31; z>=0; z--)
|
||||||
|
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||||
|
}
|
||||||
|
fprintf(stderr," sma\n");*/
|
||||||
|
//nbits = bnTarget.GetCompact();
|
||||||
|
//nbits = (nbits & 0xfffffffc) | 0;
|
||||||
|
//return(nbits);
|
||||||
|
}
|
||||||
easy.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
easy.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||||
if ( pblock != 0 )
|
if ( pblock != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user