From ca3ba90bc83e14ab8209ca614b655a027d91242e Mon Sep 17 00:00:00 2001 From: Sunny King Date: Wed, 21 Dec 2011 21:09:38 +0000 Subject: [PATCH] PPCoin: default ports; disabling irc; dns seeds; ThreadOpenConnections fix --- src/bitcoinrpc.cpp | 7 ++++--- src/init.cpp | 4 ++-- src/net.cpp | 22 ++++++++++++++-------- src/protocol.h | 7 ++++++- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 3ff5c60..1ab67c1 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2011 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -2182,7 +2183,7 @@ void ThreadRPCServer2(void* parg) asio::ip::address bindAddress = mapArgs.count("-rpcallowip") ? asio::ip::address_v4::any() : asio::ip::address_v4::loopback(); asio::io_service io_service; - ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332)); + ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", RPC_PORT)); ip::tcp::acceptor acceptor(io_service, endpoint); acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); @@ -2359,13 +2360,13 @@ Object CallRPC(const string& strMethod, const Array& params) SSLStream sslStream(io_service, context); SSLIOStreamDevice d(sslStream, fUseSSL); iostreams::stream stream(d); - if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", "8332"))) + if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", CBigNum(RPC_PORT).ToString().c_str()))) throw runtime_error("couldn't connect to server"); #else if (fUseSSL) throw runtime_error("-rpcssl=1, but bitcoin compiled without full openssl libraries."); - ip::tcp::iostream stream(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", "8332")); + ip::tcp::iostream stream(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", CBigNum(RPC_PORT).ToString().c_str())); if (stream.fail()) throw runtime_error("couldn't connect to server"); #endif diff --git a/src/init.cpp b/src/init.cpp index d36f1dd..d545c82 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -189,7 +189,7 @@ bool AppInit2(int argc, char* argv[]) " -timeout= \t " + _("Specify connection timeout (in milliseconds)\n") + " -proxy= \t " + _("Connect through socks4 proxy\n") + " -dns \t " + _("Allow DNS lookups for addnode and connect\n") + - " -port= \t\t " + _("Listen for connections on (default: 8333 or testnet: 18333)\n") + + " -port= \t\t " + _("Listen for connections on (default: 9901 or testnet: 9903)\n") + " -maxconnections=\t " + _("Maintain at most connections to peers (default: 125)\n") + " -addnode= \t " + _("Add a node to connect to\n") + " -connect= \t\t " + _("Connect only to the specified node\n") + @@ -222,7 +222,7 @@ bool AppInit2(int argc, char* argv[]) #endif " -rpcuser= \t " + _("Username for JSON-RPC connections\n") + " -rpcpassword=\t " + _("Password for JSON-RPC connections\n") + - " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 8332)\n") + + " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 9902)\n") + " -rpcallowip= \t\t " + _("Allow JSON-RPC connections from specified IP address\n") + " -rpcconnect= \t " + _("Send commands to node running on (default: 127.0.0.1)\n") + " -keypool= \t " + _("Set key pool size to (default: 100)\n") + diff --git a/src/net.cpp b/src/net.cpp index b968d5a..6ef6946 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -406,8 +406,8 @@ bool GetMyExternalIP(unsigned int& ipRet) void ThreadGetMyExternalIP(void* parg) { - // Wait for IRC to get it first - if (!GetBoolArg("-noirc")) + // Wait for IRC to get it first - disabled with ppcoin + if (false && !GetBoolArg("-noirc")) { for (int i = 0; i < 2 * 60; i++) { @@ -1222,9 +1222,10 @@ void MapPort(bool /* unused fMapPort */) - +// testnet dns seed begins with 't', all else are ppcoin dns seeds. static const char *strDNSSeed[] = { - // "seeds.ppcoin.org" + "ppcseed.zapto.org", + "tncseed.zapto.org" }; void ThreadDNSAddressSeed(void* parg) @@ -1251,13 +1252,16 @@ void ThreadDNSAddressSeed2(void* parg) printf("ThreadDNSAddressSeed started\n"); int found = 0; - if (!fTestNet) + if (true /*!fTestNet*/) // ppcoin enables dns seeding with testnet too { printf("Loading addresses from DNS seeds (could take a while)\n"); CAddrDB addrDB; addrDB.TxnBegin(); for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { + if (fTestNet && strDNSSeed[seed_idx][0] != 't') continue; + if ((!fTestNet) && strDNSSeed[seed_idx][0] == 't') continue; + vector vaddr; if (Lookup(strDNSSeed[seed_idx], vaddr, NODE_NETWORK, -1, true)) { @@ -1424,7 +1428,7 @@ void ThreadOpenConnections2(void* parg) BOOST_FOREACH(const PAIRTYPE(vector, CAddress)& item, mapAddresses) { const CAddress& addr = item.second; - if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff)) + if (addr.ip == addrLocalHost.ip || !addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff)) continue; int64 nSinceLastSeen = nANow - addr.nTime; int64 nSinceLastTry = nANow - addr.nLastTry; @@ -1748,8 +1752,10 @@ void StartNode(void* parg) MapPort(fUseUPnP); // Get addresses from IRC and advertise ours - if (!CreateThread(ThreadIRCSeed, NULL)) - printf("Error: CreateThread(ThreadIRCSeed) failed\n"); + // if (!CreateThread(ThreadIRCSeed, NULL)) + // printf("Error: CreateThread(ThreadIRCSeed) failed\n"); + // IRC disabled with ppcoin + printf("IRC seeding/communication disabled\n"); // Send and receive from sockets, accept connections if (!CreateThread(ThreadSocketHandler, NULL)) diff --git a/src/protocol.h b/src/protocol.h index 53d3eef..5943f8a 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -14,10 +14,15 @@ #include #include "uint256.h" +#define PPCOIN_PORT 9901 +#define RPC_PORT 9902 +#define TESTNET_PORT 9903 + extern bool fTestNet; + static inline unsigned short GetDefaultPort(const bool testnet = fTestNet) { - return testnet ? 18333 : 8333; + return testnet ? TESTNET_PORT : PPCOIN_PORT; } // -- 1.7.1