Skip to content

Instantly share code, notes, and snippets.

@ryancdotorg
Created June 16, 2014 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryancdotorg/d20da4c52866aba4f262 to your computer and use it in GitHub Desktop.
Save ryancdotorg/d20da4c52866aba4f262 to your computer and use it in GitHub Desktop.
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 94b4305..ed25ba8 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -2458,6 +2458,29 @@ Value verifymessage(const Array& params, bool fHelp)
return Hash160(key.GetPubKey()) == hash160;
}
+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"))
+ throw runtime_error(
+ "addnode <node> <onetry>\n"
+ "Attempts a connection to <node> once.");
+
+ string strNode = params[0].get_str();
+
+ if (strCommand == "onetry")
+ {
+ CAddress addr(strNode, true);
+ ConnectNode(addr);
+ return Value::null;
+ }
+
+ return Value::null;
+}
+
//
// Utilities: convert hex-encoded Values
// (throws error if not hex).
@@ -3034,6 +3057,7 @@ pair<string, rpcfn_type> pCallTable[] =
{
make_pair("help", &help),
make_pair("stop", &stop),
+ make_pair("addnode", &addnode),
make_pair("getblockbycount", &getblockbycount),
make_pair("getblock", &getblock),
make_pair("getblockcount", &getblockcount),
diff --git a/src/net.cpp b/src/net.cpp
index a28b72e..80806d0 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -63,6 +63,9 @@ deque<pair<int64, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
map<CInv, int64> mapAlreadyAskedFor;
+vector<std::string> vAddedNodes;
+CCriticalSection cs_vAddedNodes;
+
// Settings
int fUseProxy = false;
int nConnectTimeout = 5000;
diff --git a/src/net.h b/src/net.h
index 077f824..2a65b64 100644
--- a/src/net.h
+++ b/src/net.h
@@ -489,6 +489,9 @@ extern std::deque<std::pair<int64, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
extern std::map<CInv, int64> mapAlreadyAskedFor;
+extern std::vector<std::string> vAddedNodes;
+extern CCriticalSection cs_vAddedNodes;
+
// Settings
extern int fUseProxy;
extern CAddress addrProxy;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment