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

@@ -1179,7 +1179,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
view.GetBestBlock();
nValueIn = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime);
if ( interest != 0 )
if ( 0 && interest != 0 )
fprintf(stderr,"add interest %.8f\n",(double)interest/COIN);
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
view.SetBackend(dummy);

View File

@@ -40,6 +40,7 @@ using namespace std;
* Or alternatively, create a specific query method for the information.
**/
uint64_t komodo_interestsum();
int32_t komodo_longestchain();
int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp);
Value getinfo(const Array& params, bool fHelp)
@@ -98,6 +99,7 @@ Value getinfo(const Array& params, bool fHelp)
}
#endif
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("longestchain", komodo_longestchain()));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
if ( chainActive.Tip() != 0 )
obj.push_back(Pair("tiptime", (int)chainActive.Tip()->nTime));

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;