Search in sources :

Example 1 with DnsSeedDiscovery

use of org.bitcoinj.net.discovery.DnsDiscovery.DnsSeedDiscovery in project bitcoinj by bitcoinj.

the class MultiplexingDiscovery method forServices.

/**
 * Builds a suitable set of peer discoveries.
 * @param params Network to use.
 * @param services Required services as a bitmask, e.g. {@link VersionMessage#NODE_NETWORK}.
 * @param parallelQueries When true, seeds are queried in parallel
 * @param shufflePeers When true, queried peers are shuffled
 */
public static MultiplexingDiscovery forServices(NetworkParameters params, long services, boolean parallelQueries, boolean shufflePeers) {
    List<PeerDiscovery> discoveries = new ArrayList<>();
    HttpDiscovery.Details[] httpSeeds = params.getHttpSeeds();
    if (httpSeeds != null) {
        OkHttpClient httpClient = new OkHttpClient();
        for (HttpDiscovery.Details httpSeed : httpSeeds) discoveries.add(new HttpDiscovery(params, httpSeed, httpClient));
    }
    String[] dnsSeeds = params.getDnsSeeds();
    if (dnsSeeds != null)
        for (String dnsSeed : dnsSeeds) discoveries.add(new DnsSeedDiscovery(params, dnsSeed));
    return new MultiplexingDiscovery(params, discoveries, parallelQueries, shufflePeers);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) ArrayList(java.util.ArrayList) DnsSeedDiscovery(org.bitcoinj.net.discovery.DnsDiscovery.DnsSeedDiscovery)

Aggregations

ArrayList (java.util.ArrayList)1 OkHttpClient (okhttp3.OkHttpClient)1 DnsSeedDiscovery (org.bitcoinj.net.discovery.DnsDiscovery.DnsSeedDiscovery)1