aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-04-16 15:59:10 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:06:24 -0400
commitb1a5f4320878e34eb998737dce333270dd83e436 (patch)
tree2b1a9a94fb1008b3e4b1936fb55d3e83cb998aac
parent02137f11e2ea5d153f433493639730587836a1e3 (diff)
downloadbitcoin-b1a5f4320878e34eb998737dce333270dd83e436.tar.xz
net: move OpenNetworkConnection into CConnman
-rw-r--r--src/net.cpp4
-rw-r--r--src/net.h4
-rw-r--r--src/rpc/net.cpp5
3 files changed, 9 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 0069820004..83a96205a3 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -375,7 +375,7 @@ CNode* FindNode(const NodeId nodeid)
return NULL;
}
-CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure)
+CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure)
{
if (pszDest == NULL) {
if (IsLocal(addrConnect))
@@ -1809,7 +1809,7 @@ void CConnman::ThreadOpenAddedConnections()
}
// if successful, this moves the passed grant to the constructed node
-bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler)
+bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler)
{
//
// Initiate outbound network connection
diff --git a/src/net.h b/src/net.h
index 4d87408e32..e0c317ae46 100644
--- a/src/net.h
+++ b/src/net.h
@@ -93,7 +93,6 @@ CNode* FindNode(const CSubNet& subNet);
CNode* FindNode(const std::string& addrName);
CNode* FindNode(const CService& ip);
CNode* FindNode(const NodeId id); //TODO: Remove this
-bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false);
class CConnman
{
@@ -103,6 +102,7 @@ public:
bool Start(boost::thread_group& threadGroup, std::string& strNodeError);
void Stop();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
+ bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false);
private:
struct ListenSocket {
@@ -120,6 +120,8 @@ private:
void ThreadSocketHandler();
void ThreadDNSAddressSeed();
+ CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure);
+
std::vector<ListenSocket> vhListenSocket;
};
extern std::unique_ptr<CConnman> g_connman;
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 840bfd5a24..edf33c70be 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -214,12 +214,15 @@ UniValue addnode(const UniValue& params, bool fHelp)
+ HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")
);
+ if(!g_connman)
+ throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
+
string strNode = params[0].get_str();
if (strCommand == "onetry")
{
CAddress addr;
- OpenNetworkConnection(addr, false, NULL, strNode.c_str());
+ g_connman->OpenNetworkConnection(addr, false, NULL, strNode.c_str());
return NullUniValue;
}