diff --git a/src/rpcmasternode.cpp b/src/rpcmasternode.cpp index 52ae72d79..e06203720 100644 --- a/src/rpcmasternode.cpp +++ b/src/rpcmasternode.cpp @@ -128,7 +128,7 @@ Value masternode(const Array& params, bool fHelp) (strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "stop" && strCommand != "stop-alias" && strCommand != "stop-many" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && strCommand != "enforce" && strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" && - strCommand != "outputs" && strCommand != "status")) + strCommand != "outputs" && strCommand != "status" && strCommand != "calcscore")) throw runtime_error( "masternode \"command\"... ( \"passphrase\" )\n" "Set of commands to execute masternode related actions\n" @@ -467,6 +467,36 @@ Value masternode(const Array& params, bool fHelp) return obj; } + /* + Shows which masternode wins by score each block + */ + if (strCommand == "calcscore") + { + int nLast = 10; + + if (params.size() >= 2){ + nLast = atoi(params[1].get_str()); + } + Object obj; + + std::vector vMasternodes = mnodeman.GetFullMasternodeVector(); + for(int nHeight = chainActive.Tip()->nHeight-nLast; nHeight < chainActive.Tip()->nHeight+20; nHeight++){ + uint256 nHigh = 0; + CMasternode *pBestMasternode = NULL; + BOOST_FOREACH(CMasternode& mn, vMasternodes) { + uint256 n = mn.CalculateScore(1, nHeight-100); + if(n > nHigh){ + nHigh = n; + pBestMasternode = &mn; + } + } + if(pBestMasternode) + obj.push_back(Pair(strprintf("%d", nHeight), pBestMasternode->vin.prevout.ToStringShort().c_str())); + } + + return obj; + } + return Value::null; }