fix segid in pindex, fix help. Remove more pointless prints.
This commit is contained in:
@@ -2055,7 +2055,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
|
||||
return(blocktime);
|
||||
}
|
||||
}
|
||||
} else fprintf(stderr,"maxiters is not good enough\n");
|
||||
} //else fprintf(stderr,"maxiters is not good enough\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -2186,7 +2186,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
decode_hex((uint8_t *)utxotxidp,32,(char *)kp->txid.GetHex().c_str());
|
||||
*utxovoutp = kp->vout;
|
||||
*txtimep = kp->txtime;//(uint32_t)out.tx->nLockTime;
|
||||
fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners);
|
||||
//fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners);
|
||||
}
|
||||
} //else fprintf(stderr,"utxo not eligible\n");
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
|
||||
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
|
||||
int32_t komodo_longestchain();
|
||||
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
||||
extern int8_t komodo_segid(int32_t nocache,int32_t height);
|
||||
extern int32_t KOMODO_LONGESTCHAIN;
|
||||
|
||||
double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty)
|
||||
@@ -147,7 +148,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
|
||||
result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits)));
|
||||
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
||||
result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex()));
|
||||
result.push_back(Pair("segid", (int64_t)blockindex->segid));
|
||||
result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight())));
|
||||
|
||||
if (blockindex->pprev)
|
||||
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
|
||||
@@ -174,7 +175,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
|
||||
result.push_back(Pair("height", blockindex->GetHeight()));
|
||||
result.push_back(Pair("version", block.nVersion));
|
||||
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
|
||||
result.push_back(Pair("segid", (int64_t)blockindex->segid));
|
||||
result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight())));
|
||||
|
||||
UniValue deltas(UniValue::VARR);
|
||||
|
||||
@@ -292,7 +293,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||
result.push_back(Pair("height", blockindex->GetHeight()));
|
||||
result.push_back(Pair("version", block.nVersion));
|
||||
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
|
||||
result.push_back(Pair("segid", (int64_t)blockindex->segid));
|
||||
result.push_back(Pair("segid", (int)komodo_segid(0,blockindex->GetHeight())));
|
||||
result.push_back(Pair("finalsaplingroot", block.hashFinalSaplingRoot.GetHex()));
|
||||
UniValue txs(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTransaction&tx, block.vtx)
|
||||
@@ -647,22 +648,39 @@ UniValue getlastsegidstakes(const UniValue& params, bool fHelp)
|
||||
LOCK(cs_main);
|
||||
|
||||
int depth = params[0].get_int();
|
||||
if ( depth > chainActive.Height() )
|
||||
throw runtime_error("Not enough blocks to scan back that far.\n");
|
||||
|
||||
int32_t segids[64] = {0};
|
||||
int32_t pow = 0;
|
||||
int32_t notset = 0;
|
||||
|
||||
for (int64_t i = chainActive.Height(); i > chainActive.Height()-depth; i--)
|
||||
{
|
||||
CBlockIndex* pblockindex = chainActive[i];
|
||||
if ( pblockindex->segid >= 0 )
|
||||
segids[pblockindex->segid] += 1;
|
||||
int8_t segid = komodo_segid(0,i);
|
||||
//CBlockIndex* pblockindex = chainActive[i];
|
||||
if ( segid >= 0 )
|
||||
segids[segid] += 1;
|
||||
else if ( segid == -1 )
|
||||
pow++;
|
||||
else
|
||||
notset++;
|
||||
}
|
||||
|
||||
|
||||
int8_t posperc = 100*(depth-pow)/depth;
|
||||
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
UniValue objsegids(UniValue::VOBJ);
|
||||
for (int8_t i = 0; i < 64; i++)
|
||||
{
|
||||
char str[4];
|
||||
sprintf(str, "%d", i);
|
||||
ret.push_back(Pair(str,segids[i]));
|
||||
objsegids.push_back(Pair(str,segids[i]));
|
||||
}
|
||||
ret.push_back(Pair("NotSet",notset));
|
||||
ret.push_back(Pair("PoW",pow));
|
||||
ret.push_back(Pair("PoSPerc",posperc));
|
||||
ret.push_back(Pair("SegIds",objsegids));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -382,10 +382,10 @@ UniValue getimports(const UniValue& params, bool fHelp)
|
||||
" \"time\" : (numeric)\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"")
|
||||
+ HelpExampleRpc("getmigrates", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"")
|
||||
+ HelpExampleCli("getmigrates", "12800")
|
||||
+ HelpExampleRpc("getmigrates", "12800")
|
||||
+ HelpExampleCli("getimports", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"")
|
||||
+ HelpExampleRpc("getimports", "\"00000000febc373a1da2bd9f887b105ad79ddc26ac26c2b28652d64e5207c5b5\"")
|
||||
+ HelpExampleCli("getimports", "12800")
|
||||
+ HelpExampleRpc("getimports", "12800")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
@@ -689,7 +689,11 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||
pindexNew->nTx = diskindex.nTx;
|
||||
pindexNew->nSproutValue = diskindex.nSproutValue;
|
||||
pindexNew->nSaplingValue = diskindex.nSaplingValue;
|
||||
|
||||
pindexNew->segid = diskindex.segid;
|
||||
pindexNew->newcoins = diskindex.newcoins;
|
||||
pindexNew->zfunds = diskindex.zfunds;
|
||||
pindexNew->sproutfunds = diskindex.sproutfunds;
|
||||
|
||||
// Consistency checks
|
||||
auto header = pindexNew->GetBlockHeader();
|
||||
if (header.GetHash() != pindexNew->GetBlockHash())
|
||||
|
||||
Reference in New Issue
Block a user