aboutsummaryrefslogtreecommitdiff
path: root/net.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-01 01:16:51 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-01 01:16:51 +0000
commit4ac57f013e20da2d0f87fff69625cbd4419089f3 (patch)
tree8120216e7ebfdc54244835dfa5650f1181b57025 /net.cpp
parent5750932cdf72ea9b5e64b8a05b43c42f5acb417d (diff)
move debug.log and db.log to data dir, portable GetDataDir, optimize GetBalance, fix repaint bogdown, -addnode and -? switches
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@25 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'net.cpp')
-rw-r--r--net.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/net.cpp b/net.cpp
index 22b84f9dee..8ccf48b819 100644
--- a/net.cpp
+++ b/net.cpp
@@ -21,8 +21,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect);
bool fClient = false;
uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
CAddress addrLocalHost(0, DEFAULT_PORT, nLocalServices);
-CNode nodeLocalHost(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices));
-CNode* pnodeLocalHost = &nodeLocalHost;
+CNode* pnodeLocalHost = NULL;
uint64 nLocalHostNonce = 0;
bool fShutdown = false;
array<int, 10> vnThreadsRunning;
@@ -129,7 +128,7 @@ bool GetMyExternalIP2(const CAddress& addrConnect, const char* pszGet, const cha
strLine = wxString(strLine).Trim();
CAddress addr(strLine.c_str());
printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str());
- if (addr.ip == 0 || !addr.IsRoutable())
+ if (addr.ip == 0 || addr.ip == INADDR_NONE || !addr.IsRoutable())
return false;
ipRet = addr.ip;
return true;
@@ -740,10 +739,29 @@ void ThreadOpenConnections2(void* parg)
printf("ThreadOpenConnections started\n");
// Connect to one specified address
- while (mapArgs.count("/connect"))
+ while (mapArgs.count("-connect"))
{
- OpenNetworkConnection(CAddress(mapArgs["/connect"].c_str()));
- Sleep(10000);
+ OpenNetworkConnection(CAddress(mapArgs["-connect"]));
+ for (int i = 0; i < 10; i++)
+ {
+ Sleep(1000);
+ CheckForShutdown(1);
+ }
+ }
+
+ // Connect to manually added nodes first
+ if (mapArgs.count("-addnode"))
+ {
+ foreach(string strAddr, mapMultiArgs["-addnode"])
+ {
+ CAddress addr(strAddr, NODE_NETWORK);
+ if (addr.IsValid())
+ {
+ OpenNetworkConnection(addr);
+ Sleep(1000);
+ CheckForShutdown(1);
+ }
+ }
}
// Initiate network connections
@@ -967,6 +985,8 @@ void ThreadMessageHandler2(void* parg)
bool StartNode(string& strError)
{
+ if (pnodeLocalHost == NULL)
+ pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices));
strError = "";
// Sockets startup
@@ -1031,7 +1051,7 @@ bool StartNode(string& strError)
printf("%s\n", strError.c_str());
return false;
}
- printf("bound to addrLocalHost = %s\n\n", addrLocalHost.ToString().c_str());
+ printf("bound to addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
// Listen for incoming connections
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)