make soft checkpoint less verbose

This commit is contained in:
Miguel Freitas 2014-02-14 17:43:44 -02:00
parent 555e711b09
commit 18493205fc
5 changed files with 48 additions and 2 deletions

View File

@ -241,6 +241,7 @@ static const CRPCCommand vRPCCommands[] =
{ "sendrawtransaction", &sendrawtransaction, false, false },
{ "sendnewusertransaction", &sendnewusertransaction, false, false },
{ "verifychain", &verifychain, true, false },
{ "getlastsoftcheckpoint", &getlastsoftcheckpoint, true, false },
// twister dht network
{ "dhtput", &dhtput, false, true },
{ "dhtget", &dhtget, false, true },

View File

@ -194,6 +194,7 @@ extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp)
extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value verifychain(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getlastsoftcheckpoint(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value dhtput(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value dhtget(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value newpostmsg(const json_spirit::Array& params, bool fHelp);

View File

@ -5,6 +5,7 @@
#include "main.h"
#include "bitcoinrpc.h"
#include "softcheckpoint.h"
using namespace json_spirit;
using namespace std;
@ -203,3 +204,29 @@ Value verifychain(const Array& params, bool fHelp)
return VerifyDB(nCheckLevel, nCheckDepth);
}
Value getlastsoftcheckpoint(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getlastsoftcheckpoint"
"Returns votes of last soft checkpoint.");
Object result;
int height;
uint256 hash;
std::set<std::string> usernamesSet;
if( SoftCheckpoints::GetLastCPVotes(height, hash, usernamesSet) ) {
result.push_back(Pair("height", height));
result.push_back(Pair("hash", hash.GetHex()));
Array usernames;
BOOST_FOREACH(const std::string &user, usernamesSet) {
usernames.push_back(user);
}
result.push_back(Pair("usernames", usernames));
}
return result;
}

View File

@ -16,8 +16,8 @@
#include "init.h"
#include "twister.h"
#define dbgprintf OutputDebugStringF
//#define dbgprintf(...) // no debug printf
//#define dbgprintf OutputDebugStringF
#define dbgprintf(...) // no debug printf
namespace SoftCheckpoints
{
@ -266,4 +266,19 @@ namespace SoftCheckpoints
}
}
}
bool GetLastCPVotes(int &height, uint256 &hash, std::set<std::string> &usernames) {
LOCK(cs_softCP);
if (!lastSoftCP.first)
return false;
height = lastSoftCP.first;
hash = lastSoftCP.second;
usernames.clear();
BOOST_FOREACH(const CPSigMap::value_type& i, lastSoftCPSigs) {
usernames.insert(i.first);
}
return true;
}
}

View File

@ -31,6 +31,8 @@ namespace SoftCheckpoints
void RelayCP(const CSoftCheckpoint& cp, CNode* pfrom);
void RelayLastCPToNode(CNode* pnode);
bool GetLastCPVotes(int &height, uint256 &hash, std::set<std::string> &usernames);
}
class CSoftCheckpoint