com.google.bitcoin.net.discovery
Class DnsDiscovery

java.lang.Object
  extended by com.google.bitcoin.net.discovery.DnsDiscovery
All Implemented Interfaces:
PeerDiscovery

public class DnsDiscovery
extends Object
implements PeerDiscovery

Supports peer discovery through DNS.

Failure to resolve individual host names will not cause an Exception to be thrown. However, if all hosts passed fail to resolve a PeerDiscoveryException will be thrown during getPeers().

DNS seeds do not attempt to enumerate every peer on the network. getPeers(long, java.util.concurrent.TimeUnit) will return up to 30 random peers from the set of those returned within the timeout period. If you want more peers to connect to, you need to discover them via other means (like addr broadcasts).


Constructor Summary
DnsDiscovery(NetworkParameters netParams)
          Supports finding peers through DNS A records.
DnsDiscovery(String[] hostNames, NetworkParameters netParams)
          Supports finding peers through DNS A records.
 
Method Summary
 InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit)
          Returns an array of addresses.
 void shutdown()
          We don't have a way to abort a DNS lookup, so this does nothing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DnsDiscovery

public DnsDiscovery(NetworkParameters netParams)
Supports finding peers through DNS A records. Community run DNS entry points will be used.

Parameters:
netParams - Network parameters to be used for port information.

DnsDiscovery

public DnsDiscovery(String[] hostNames,
                    NetworkParameters netParams)
Supports finding peers through DNS A records.

Parameters:
hostNames - Host names to be examined for seed addresses.
netParams - Network parameters to be used for port information.
Method Detail

getPeers

public InetSocketAddress[] getPeers(long timeoutValue,
                                    TimeUnit timeoutUnit)
                             throws PeerDiscoveryException
Description copied from interface: PeerDiscovery
Returns an array of addresses. This method may block.

Specified by:
getPeers in interface PeerDiscovery
Throws:
PeerDiscoveryException

shutdown

public void shutdown()
We don't have a way to abort a DNS lookup, so this does nothing

Specified by:
shutdown in interface PeerDiscovery


Copyright © 2014. All rights reserved.