@@ -0,0 +1,2665 @@
+package org.bitcoinj.net.discovery;%0A%0Aimport org.bitcoinj.core.NetworkParameters;%0Aimport org.bitcoinj.evolution.SimplifiedMasternodeListManager;%0A%0Aimport java.net.InetSocketAddress;%0Aimport java.util.Arrays;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * This peer discovery class uses three methods to get peers.%0A *%0A * 1.  DnsSeeds from NetworkParameters%0A * 2.  Masternode list peers (using the current tip)%0A * 3.  SeedPeers from NetworkParameters%0A */%0Apublic class ThreeMethodPeerDiscovery implements PeerDiscovery %7B%0A%0A    private NetworkParameters params;%0A    private SimplifiedMasternodeListManager masternodeListManager;%0A    private PeerDiscovery normalPeerDiscovery;%0A    private SeedPeers seedPeerDiscovery;%0A%0A    /**%0A     * Instantiates a new Three method peer discovery.%0A     *%0A     * @param params                the network params%0A     * @param masternodeListManager the masternode list manager%0A     */%0A    public ThreeMethodPeerDiscovery(NetworkParameters params, SimplifiedMasternodeListManager masternodeListManager) %7B%0A        this.params = params;%0A        this.masternodeListManager = masternodeListManager;%0A        normalPeerDiscovery = MultiplexingDiscovery.forServices(params, 0);%0A        seedPeerDiscovery = new SeedPeers(params);%0A    %7D%0A%0A    @Override%0A    public InetSocketAddress%5B%5D getPeers(final long services, final long timeoutValue,%0A                                        final TimeUnit timeoutUnit) throws PeerDiscoveryException %7B%0A        final List%3CInetSocketAddress%3E peers = new LinkedList%3CInetSocketAddress%3E();%0A%0A        try %7B%0A            peers.addAll(%0A                    Arrays.asList(normalPeerDiscovery.getPeers(services, timeoutValue, timeoutUnit)));%0A        %7D catch (PeerDiscoveryException x) %7B%0A            //swallow and continue with another method of connection.%0A        %7D%0A        if(peers.size() %3C 10) %7B%0A            try %7B%0A                MasternodePeerDiscovery discovery = new MasternodePeerDiscovery(masternodeListManager.getListAtChainTip());%0A                peers.addAll(Arrays.asList(discovery.getPeers(services, timeoutValue, timeoutUnit)));%0A            %7D catch (PeerDiscoveryException x) %7B%0A                //swallow and continue with another method of connection%0A            %7D%0A%0A            if(peers.size() %3C 10) %7B%0A                if (params.getAddrSeeds() != null) %7B%0A                    peers.addAll(Arrays.asList(seedPeerDiscovery.getPeers(services, timeoutValue, timeoutUnit)));%0A                %7D%0A            %7D%0A        %7D%0A        return peers.toArray(new InetSocketAddress%5B0%5D);%0A    %7D%0A%0A    @Override%0A    public void shutdown() %7B%0A        normalPeerDiscovery.shutdown();%0A    %7D%0A%7D%0A

Add ThreeMethodPeerDiscovery which uses DNS, MasternodeList and SeedPeers