This commit is contained in:
jl777
2016-11-19 17:01:44 -03:00
parent 2e98c3a27a
commit f595c2e0f8
3 changed files with 33 additions and 1 deletions

View File

@@ -165,6 +165,36 @@ Value getpeerinfo(const Array& params, bool fHelp)
return ret;
}
int32_t komodo_longestchain()
{
int32_t ht,n=0,num=0,maxheight=0,height = 0;
LOCK(cs_main);
vector<CNodeStats> vstats;
CopyNodeStats(vstats);
BOOST_FOREACH(const CNodeStats& stats, vstats)
{
CNodeStateStats statestats;
bool fStateStats = GetNodeStateStats(stats.nodeid,statestats);
ht = 0;
if ( stats.nStartingHeight > ht )
ht = stats.nStartingHeight;
if ( stats.nSyncHeight > ht )
ht = stats.nSyncHeight;
if ( stats.nCommonHeight > ht )
ht = stats.nCommonHeight;
if ( maxheight == 0 || ht > maxheight*1.01 )
maxheight = ht, num = 1;
else if ( ht > maxheight*0.99 )
num++;
n++;
if ( ht > height )
height = ht;
}
if ( num > (n >> 1) )
return(height);
else return(0);
}
Value addnode(const Array& params, bool fHelp)
{
string strCommand;