diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-09-28 08:03:45 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-09-28 08:03:45 -0700 |
commit | 842a31ad1bea930c7ae2adcea929e3b8f0febfed (patch) | |
tree | d30d28717489bde59981c62fe5b7cd1d617f932e /src/bitcoinrpc.cpp | |
parent | 035cb4781d9463eb6db2574b18452c02c370c9a5 (diff) | |
parent | b202d430762c1b5c9925e948f357c66040f95f10 (diff) |
Merge pull request #1862 from kjj2/testports
Fix: when testnet=1 specified, change default RPC port to 18332
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r-- | src/bitcoinrpc.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 03d142f858..16260ef1f7 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -41,6 +41,11 @@ const Object emptyobj; void ThreadRPCServer3(void* parg); +static inline unsigned short GetDefaultRPCPort() +{ + return GetBoolArg("-testnet", false) ? 18332 : 8332; +} + Object JSONRPCError(int code, const string& message) { Object error; @@ -764,7 +769,7 @@ void ThreadRPCServer2(void* parg) // Try a dual IPv6/IPv4 socket, falling back to separate IPv4 and IPv6 sockets const bool loopback = !mapArgs.count("-rpcallowip"); asio::ip::address bindAddress = loopback ? asio::ip::address_v6::loopback() : asio::ip::address_v6::any(); - ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332)); + ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", GetDefaultRPCPort())); boost::system::error_code v6_only_error; boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(io_service)); @@ -1059,7 +1064,7 @@ Object CallRPC(const string& strMethod, const Array& params) asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context); SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL); iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > 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", itostr(GetDefaultRPCPort())))) throw runtime_error("couldn't connect to server"); // HTTP basic authentication |