Java Code Examples for org.bitcoinj.core.NetworkParameters#getHttpSeeds()

The following examples show how to use org.bitcoinj.core.NetworkParameters#getHttpSeeds() . 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: MultiplexingDiscovery.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Builds a suitable set of peer discoveries. Will query them in parallel before producing a merged response.
 * If specific services are required, DNS is not used as the protocol can't handle it.
 *
 * @param params   Network to use.
 * @param services Required services as a bitmask, e.g. {@link VersionMessage#NODE_NETWORK}.
 */
public static MultiplexingDiscovery forServices(NetworkParameters params, long services) {
    List<PeerDiscovery> discoveries = Lists.newArrayList();
    HttpDiscovery.Details[] httpSeeds = params.getHttpSeeds();
    if (httpSeeds != null) {
        OkHttpClient httpClient = new OkHttpClient();
        for (HttpDiscovery.Details httpSeed : httpSeeds)
            discoveries.add(new HttpDiscovery(params, httpSeed, httpClient));
    }
    // Also use DNS seeds if there is no specific service requirement
    if (services == 0) {
        String[] dnsSeeds = params.getDnsSeeds();
        if (dnsSeeds != null)
            for (String dnsSeed : dnsSeeds)
                discoveries.add(new DnsSeedDiscovery(params, dnsSeed));
    }
    return new MultiplexingDiscovery(params, discoveries);
}
 
Example 2
Source File: MultiplexingDiscovery.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Builds a suitable set of peer discoveries. Will query them in parallel before producing a merged response.
 * If specific services are required, DNS is not used as the protocol can't handle it.
 * @param params Network to use.
 * @param services Required services as a bitmask, e.g. {@link VersionMessage#NODE_NETWORK}.
 */
public static MultiplexingDiscovery forServices(NetworkParameters params, long services) {
    List<PeerDiscovery> discoveries = Lists.newArrayList();
    HttpDiscovery.Details[] httpSeeds = params.getHttpSeeds();
    if (httpSeeds != null) {
        OkHttpClient httpClient = new OkHttpClient();
        for (HttpDiscovery.Details httpSeed : httpSeeds)
            discoveries.add(new HttpDiscovery(params, httpSeed, httpClient));
    }
    // Also use DNS seeds if there is no specific service requirement
    if (services == 0) {
        String[] dnsSeeds = params.getDnsSeeds();
        if (dnsSeeds != null)
            for (String dnsSeed : dnsSeeds)
                discoveries.add(new DnsSeedDiscovery(params, dnsSeed));
    }
    return new MultiplexingDiscovery(params, discoveries);
}
 
Example 3
Source File: MultiplexingDiscovery.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Builds a suitable set of peer discoveries. Will query them in parallel before producing a merged response.
 * If specific services are required, DNS is not used as the protocol can't handle it.
 * @param params Network to use.
 * @param services Required services as a bitmask, e.g. {@link VersionMessage#NODE_NETWORK}.
 */
public static MultiplexingDiscovery forServices(NetworkParameters params, long services) {
    List<PeerDiscovery> discoveries = Lists.newArrayList();
    HttpDiscovery.Details[] httpSeeds = params.getHttpSeeds();
    if (httpSeeds != null) {
        OkHttpClient httpClient = new OkHttpClient();
        for (HttpDiscovery.Details httpSeed : httpSeeds)
            discoveries.add(new HttpDiscovery(params, httpSeed, httpClient));
    }
    // Also use DNS seeds if there is no specific service requirement
    if (services == 0) {
        String[] dnsSeeds = params.getDnsSeeds();
        if (dnsSeeds != null)
            for (String dnsSeed : dnsSeeds)
                discoveries.add(new DnsSeedDiscovery(params, dnsSeed));
    }
    return new MultiplexingDiscovery(params, discoveries);
}