Add unl_delete command.

This commit is contained in:
Arthur Britto
2012-03-21 14:37:44 -07:00
parent 69d492f4e5
commit d070b10f21

View File

@@ -67,7 +67,7 @@ void RPCServer::handle_read(const boost::system::error_code& e,
} }
else if(e != boost::asio::error::operation_aborted) else if(e != boost::asio::error::operation_aborted)
{ {
} }
} }
@@ -75,7 +75,7 @@ std::string RPCServer::handleRequest(const std::string& requestStr)
{ {
std::cout << "handleRequest " << requestStr << std::endl; std::cout << "handleRequest " << requestStr << std::endl;
Json::Value id; Json::Value id;
// Parse request // Parse request
Json::Value valRequest; Json::Value valRequest;
Json::Reader reader; Json::Reader reader;
@@ -497,21 +497,21 @@ Json::Value RPCServer::doLedger(Json::Value& params)
return "not implemented"; return "not implemented";
} }
// unl_add <node_public>
// unl_add <node_public> <comment>
Json::Value RPCServer::doUnlAdd(Json::Value& params) { Json::Value RPCServer::doUnlAdd(Json::Value& params) {
// unl_add <node_public>
// unl_add <node_public> <comment>
if(params.size()==1 || params.size()==2) if(params.size()==1 || params.size()==2)
{ {
std::string pubKey=params[0u].asString(); std::string strNodePublic=params[0u].asString();
std::string comment=params.size() == 2 std::string strComment=params.size() == 2
? "" ? ""
: params[1u].asString(); : params[1u].asString();
NewcoinAddress nodePublic; NewcoinAddress nodePublic;
if(nodePublic.setNodePublic(pubKey)) if(nodePublic.setNodePublic(strNodePublic))
{ {
theApp->getUNL().addNode(nodePublic, comment); theApp->getUNL().addNode(nodePublic, strComment);
return "adding node"; return "adding node";
} }
@@ -527,8 +527,26 @@ Json::Value RPCServer::doUnlDefault(Json::Value& params) {
return "not implemented"; return "not implemented";
} }
// unl_delete <hanko>
Json::Value RPCServer::doUnlDelete(Json::Value& params) { Json::Value RPCServer::doUnlDelete(Json::Value& params) {
return "not implemented"; if(params.size()==1)
{
std::string strHanko=params[0u].asString();
NewcoinAddress hanko;
if(hanko.setHanko(strHanko))
{
theApp->getUNL().removeNode(hanko);
return "removing node";
}
else
{
return "invalid hanko";
}
}
else return "invalid params";
} }
Json::Value RPCServer::doUnlFetch(Json::Value& params) { Json::Value RPCServer::doUnlFetch(Json::Value& params) {