Skip to content

Commit

Permalink
Fix Tor support does not use all available HTTP seeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Aug 24, 2015
1 parent 2c8ffc8 commit a12ec7f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/src/main/java/org/bitcoinj/core/PeerGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,12 @@ public static PeerGroup newWithTor(Context context, @Nullable AbstractBlockChain
HttpDiscovery.Details[] httpSeeds = params.getHttpSeeds();
if (httpSeeds.length > 0) {
// Use HTTP discovery when Tor is active and there is a Cartographer seed, for a much needed speed boost.
OkHttpClient client = new OkHttpClient();
client.setSocketFactory(torClient.getSocketFactory());
result.addPeerDiscovery(new HttpDiscovery(params, httpSeeds[0], client));
OkHttpClient httpClient = new OkHttpClient();
httpClient.setSocketFactory(torClient.getSocketFactory());
List<PeerDiscovery> discoveries = Lists.newArrayList();
for (HttpDiscovery.Details httpSeed : httpSeeds)
discoveries.add(new HttpDiscovery(params, httpSeed, httpClient));
result.addPeerDiscovery(new MultiplexingDiscovery(params, discoveries));
} else {
result.addPeerDiscovery(new TorDiscovery(params, torClient));
}
Expand Down

0 comments on commit a12ec7f

Please sign in to comment.