X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Frpcnet.cpp;h=5078a7986b0d20ff9da7ca3b2b8ae8830a7e2ece;hp=3b283d9db28bcdfe52e3ad1aad623848d8b36603;hb=5e16a8b47dcc39875b55e578ba1c4dd929fa1332;hpb=41ac223d5f00d7b45b774ac4cb348938419e787a diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 3b283d9..5078a79 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -72,6 +72,49 @@ Value getpeerinfo(const Array& params, bool fHelp) return ret; } +Value addnode(const Array& params, bool fHelp) +{ + string strCommand; + if (params.size() == 2) + strCommand = params[1].get_str(); + if (fHelp || params.size() != 2 || + (strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) + throw runtime_error( + "addnode \n" + "Attempts add or remove from the addnode list or try a connection to once."); + + string strNode = params[0].get_str(); + + if (strCommand == "onetry") + { + CAddress addr; + ConnectNode(addr, strNode.c_str()); + return Value::null; + } + + LOCK(cs_vAddedNodes); + vector::iterator it = vAddedNodes.begin(); + for(; it != vAddedNodes.end(); it++) + if (strNode == *it) + break; + + if (strCommand == "add") + { + if (it != vAddedNodes.end()) + throw JSONRPCError(-23, "Error: Node already added"); + vAddedNodes.push_back(strNode); + } + else if(strCommand == "remove") + { + if (it == vAddedNodes.end()) + throw JSONRPCError(-24, "Error: Node has not been added."); + vAddedNodes.erase(it); + } + + return Value::null; +} + + extern CCriticalSection cs_mapAlerts; extern map mapAlerts;