Use actual target met
This commit is contained in:
10
src/pow.cpp
10
src/pow.cpp
@@ -230,9 +230,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
bnPrev.SetCompact(pindexFirst->nBits);
|
bnPrev.SetCompact(pindexFirst->nBits);
|
||||||
for (i=0; pindexFirst != 0 && i<(int32_t)(sizeof(ct)/sizeof(*ct)); i++)
|
for (i=0; pindexFirst != 0 && i<(int32_t)(sizeof(ct)/sizeof(*ct)); i++)
|
||||||
{
|
{
|
||||||
ct[i].SetCompact(pindexFirst->nBits);
|
|
||||||
if ( (pindexFirst->nBits&3) != 0 )
|
if ( (pindexFirst->nBits&3) != 0 )
|
||||||
|
{
|
||||||
|
ct[i] = UintToArith256(pindexFirst->GetBlockHash());
|
||||||
ct[i] /= arith_uint256((pindexFirst->nBits&3) + 1);
|
ct[i] /= arith_uint256((pindexFirst->nBits&3) + 1);
|
||||||
|
} else ct[i].SetCompact(pindexFirst->nBits);
|
||||||
ts[i] = pindexFirst->nTime;
|
ts[i] = pindexFirst->nTime;
|
||||||
pindexFirst = pindexFirst->pprev;
|
pindexFirst = pindexFirst->pprev;
|
||||||
}
|
}
|
||||||
@@ -256,11 +258,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( pindexFirst->GetHeight() >= (int32_t)(sizeof(ct)/sizeof(*ct)) && (pindexFirst->nBits&3) != 0 )
|
if ( pindexFirst->GetHeight() >= (int32_t)(sizeof(ct)/sizeof(*ct)) && (pindexFirst->nBits&3) != 0 )
|
||||||
{
|
bnTmp = ct[i];
|
||||||
bnTmp /= arith_uint256((pindexFirst->nBits&3) + 1); // check against ct[i]
|
|
||||||
if ( ct[i] != bnTmp )
|
|
||||||
fprintf(stderr,"ht.%d i.%d ct[] != bnTmp boost X%d\n",height,i,(int32_t)(pindexFirst->nBits&3) + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bnTot += bnTmp;
|
bnTot += bnTmp;
|
||||||
pindexFirst = pindexFirst->pprev;
|
pindexFirst = pindexFirst->pprev;
|
||||||
|
|||||||
@@ -407,28 +407,32 @@ CBlockIndex *komodo_chainactive(int32_t height);
|
|||||||
|
|
||||||
UniValue genminingCSV(const UniValue& params, bool fHelp)
|
UniValue genminingCSV(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
int32_t i,z,height; FILE *fp; char str[64],fname[256]; arith_uint256 bnTarget; CBlockIndex *pindex; bool fNegative,fOverflow; UniValue result(UniValue::VOBJ);
|
int32_t i,z,height; FILE *fp; char str[65],str2[65],fname[256]; uint256 hash; arith_uint256 bnTarget; CBlockIndex *pindex; bool fNegative,fOverflow; UniValue result(UniValue::VOBJ);
|
||||||
if (fHelp || params.size() != 0 )
|
if (fHelp || params.size() != 0 )
|
||||||
throw runtime_error("genminingCSV\n");
|
throw runtime_error("genminingCSV\n");
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
sprintf(fname,"%s_mining.csv",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL);
|
sprintf(fname,"%s_mining.csv",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL);
|
||||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(fp,"height,nTime,nBits,bnTarget,diff,netdiff\n");
|
fprintf(fp,"height,nTime,nBits,bnTarget,blockhash,diff,netdiff\n");
|
||||||
height = komodo_nextheight();
|
height = komodo_nextheight();
|
||||||
for (i=0; i<height; i++)
|
for (i=0; i<height; i++)
|
||||||
{
|
{
|
||||||
if ( (pindex= komodo_chainactive(i)) != 0 )
|
if ( (pindex= komodo_chainactive(i)) != 0 )
|
||||||
{
|
{
|
||||||
bnTarget.SetCompact(pindex->nBits,&fNegative,&fOverflow);
|
bnTarget.SetCompact(pindex->nBits,&fNegative,&fOverflow);
|
||||||
for (z=0; z<32; z++)
|
for (z=0; z<16; z++)
|
||||||
sprintf(&str[z<<1],"%02x",((uint8_t *)&bnTarget)[31-z]);
|
sprintf(&str[z<<1],"%02x",((uint8_t *)&bnTarget)[31-z]);
|
||||||
str[32] = 0; fprintf(fp,"%d,%u,%u,%s,%.8f,%.8f\n",i,pindex->nTime,pindex->nBits,str,GetDifficulty(pindex),GetNetworkDifficulty(pindex));
|
str[32] = 0;
|
||||||
|
hash = pindex->GetBlockHash();
|
||||||
|
for (z=0; z<16; z++)
|
||||||
|
sprintf(&strw[z<<1],"%02x",((uint8_t *)&hash)[31-z]);
|
||||||
|
strw[32] = 0; fprintf(fp,"%d,%u,%u,%s,%s,%.8f,%.8f\n",i,pindex->nTime,pindex->nBits,str,str2,GetDifficulty(pindex),GetNetworkDifficulty(pindex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
result.push_back(Pair("result", "success"));
|
result.push_back(Pair("result", "success"));
|
||||||
result.push_back(Pair("created", "COIN_mining.csv"));
|
result.push_back(Pair("created", fname));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user