From c137a204fbeb59ae73b68c137fef640808f652b3 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Fri, 24 Jul 2015 08:21:02 -0700 Subject: [PATCH] Added calcscore cmd --- src/rpcmasternode.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/rpcmasternode.cpp b/src/rpcmasternode.cpp index 52ae72d79f..e062037209 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; }