Search in sources :

Example 1 with BlockingClientManager

use of org.bitcoinj.net.BlockingClientManager in project bisq-core by bisq-network.

the class WalletConfig method createPeerGroup.

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;
    }
}
Also used : ProxySocketFactory(bisq.core.btc.ProxySocketFactory) BlockingClientManager(org.bitcoinj.net.BlockingClientManager) Proxy(java.net.Proxy) Socks5Proxy(com.runjva.sourceforge.jsocks.protocol.Socks5Proxy) InetSocketAddress(java.net.InetSocketAddress) PeerGroup(org.bitcoinj.core.PeerGroup)

Example 2 with BlockingClientManager

use of org.bitcoinj.net.BlockingClientManager in project bitsquare by bitsquare.

the class WalletAppKitBitSquare method createPeerGroup.

protected PeerGroup createPeerGroup() throws TimeoutException {
    // no proxy case.
    if (socks5Proxy == null || isLocalHostFullNodeRunning()) {
        return super.createPeerGroup();
    } else {
        // proxy case.
        Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(socks5Proxy.getInetAddress().getHostName(), socks5Proxy.getPort()));
        // same value used in bitcoinj.
        int CONNECT_TIMEOUT_MSEC = 60 * 1000;
        ProxySocketFactory proxySocketFactory = new ProxySocketFactory(proxy);
        BlockingClientManager mgr = new BlockingClientManager(proxySocketFactory);
        PeerGroup peerGroup = new PeerGroup(params, vChain, mgr);
        mgr.setConnectTimeoutMillis(CONNECT_TIMEOUT_MSEC);
        peerGroup.setConnectTimeoutMillis(CONNECT_TIMEOUT_MSEC);
        return peerGroup;
    }
}
Also used : BlockingClientManager(org.bitcoinj.net.BlockingClientManager) Proxy(java.net.Proxy) Socks5Proxy(com.runjva.sourceforge.jsocks.protocol.Socks5Proxy) InetSocketAddress(java.net.InetSocketAddress) PeerGroup(org.bitcoinj.core.PeerGroup)

Aggregations

Socks5Proxy (com.runjva.sourceforge.jsocks.protocol.Socks5Proxy)2 InetSocketAddress (java.net.InetSocketAddress)2 Proxy (java.net.Proxy)2 PeerGroup (org.bitcoinj.core.PeerGroup)2 BlockingClientManager (org.bitcoinj.net.BlockingClientManager)2 ProxySocketFactory (bisq.core.btc.ProxySocketFactory)1