bnTargetB in CSV
This commit is contained in:
12
src/pow.cpp
12
src/pow.cpp
@@ -187,6 +187,16 @@ arith_uint256 zawy_exponential(arith_uint256 bnTarget,int32_t mult)
|
|||||||
|
|
||||||
// 17:03 6x at ht.255 launch for ZAWY17
|
// 17:03 6x at ht.255 launch for ZAWY17
|
||||||
|
|
||||||
|
arith_uint256 zawy_ctB(arith_uint256 bnTarget,uint32_t solvetime)
|
||||||
|
{
|
||||||
|
bnTarget /= arith_uint256(K);
|
||||||
|
bnTarget *= arith_uint256((int64_t)solvetime * solvetime * 1000);
|
||||||
|
bnTarget /= arith_uint256(T * T * 784);
|
||||||
|
bnTarget *= arith_uint256(K);
|
||||||
|
return(bnTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
||||||
@@ -245,6 +255,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
for (i=0; pindexFirst != 0 && i<(int32_t)(sizeof(ct)/sizeof(*ct))-1; i++)
|
for (i=0; pindexFirst != 0 && i<(int32_t)(sizeof(ct)/sizeof(*ct))-1; i++)
|
||||||
{
|
{
|
||||||
if ( zflags[i] != 0 )
|
if ( zflags[i] != 0 )
|
||||||
|
ct[i] = zawy_ctB(ct[i],ts[i] - ts[i+1]);
|
||||||
|
|
||||||
{
|
{
|
||||||
ct[i] /= arith_uint256(K);
|
ct[i] /= arith_uint256(K);
|
||||||
ct[i] *= arith_uint256((int64_t)(ts[i] - ts[i+1]) * (ts[i] - ts[i+1]) * 1000);
|
ct[i] *= arith_uint256((int64_t)(ts[i] - ts[i+1]) * (ts[i] - ts[i+1]) * 1000);
|
||||||
|
|||||||
@@ -404,30 +404,35 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CBlockIndex *komodo_chainactive(int32_t height);
|
CBlockIndex *komodo_chainactive(int32_t height);
|
||||||
|
arith_uint256 zawy_ctB(arith_uint256 bnTarget,uint32_t solvetime);
|
||||||
|
|
||||||
UniValue genminingCSV(const UniValue& params, bool fHelp)
|
UniValue genminingCSV(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
int32_t i,z,height; uint32_t prevtime=0; FILE *fp; char str[65],str2[65],fname[256]; uint256 hash; arith_uint256 bnTarget; CBlockIndex *pindex; bool fNegative,fOverflow; UniValue result(UniValue::VOBJ);
|
int32_t i,z,height; uint32_t solvetime,prevtime=0; 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,blockhash,diff,netdiff,solvetime\n");
|
fprintf(fp,"height,nTime,nBits,bnTarget,bnTargetB,diff,netdiff,solvetime\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);
|
||||||
|
solvetime = (prevtime==0) ? 0 : (int32_t)(pindex->nTime - prevtime);
|
||||||
for (z=0; z<16; 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;
|
str[32] = 0;
|
||||||
hash = pindex->GetBlockHash();
|
//hash = pindex->GetBlockHash();
|
||||||
|
memset(&hash,0,sizeof(hash));
|
||||||
|
if ( (pindex->nBits & 3) != 0 )
|
||||||
|
hash = zawy_ctB(bnTarget,solvetime);
|
||||||
for (z=0; z<16; z++)
|
for (z=0; z<16; z++)
|
||||||
sprintf(&str2[z<<1],"%02x",((uint8_t *)&hash)[31-z]);
|
sprintf(&str2[z<<1],"%02x",((uint8_t *)&hash)[31-z]);
|
||||||
str2[32] = 0; fprintf(fp,"%d,%u,%08x,%s,%s,%.1f,%.1f,%d\n",i,pindex->nTime,pindex->nBits,str,str2,GetDifficulty(pindex),GetNetworkDifficulty(pindex),prevtime==0?0:(int32_t)(pindex->nTime-prevtime));
|
str2[32] = 0; fprintf(fp,"%d,%u,%08x,%s,%s,%.1f,%.1f,%d\n",i,pindex->nTime,pindex->nBits,str,str2,GetDifficulty(pindex),GetNetworkDifficulty(pindex),solvetime);
|
||||||
prevtime = pindex->nTime;
|
prevtime = pindex->nTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user