org.bitcoinj.net.BlockingClientManager Java Examples

The following examples show how to use org.bitcoinj.net.BlockingClientManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WalletConfig.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
private PeerGroup createPeerGroup() {
    // no proxy case.
    if (socks5Proxy == null) {
        return new PeerGroup(params, vChain);
    } else {
        // proxy case (tor).
        Proxy proxy = new Proxy(Proxy.Type.SOCKS,
                new InetSocketAddress(socks5Proxy.getInetAddress().getHostName(),
                        socks5Proxy.getPort()));

        ProxySocketFactory proxySocketFactory = new ProxySocketFactory(proxy);
        // we dont use tor mode if we have a local node running
        BlockingClientManager blockingClientManager = bisqEnvironment.isBitcoinLocalhostNodeRunning() ?
                new BlockingClientManager() :
                new BlockingClientManager(proxySocketFactory);

        PeerGroup peerGroup = new PeerGroup(params, vChain, blockingClientManager);

        blockingClientManager.setConnectTimeoutMillis(TIMEOUT);
        peerGroup.setConnectTimeoutMillis(TIMEOUT);

        return peerGroup;
    }
}