@@ -0,0 +1,2749 @@
+package org.bitcoinj.net.discovery;%0A%0Aimport org.bitcoinj.evolution.SimplifiedMasternodeList;%0Aimport org.bitcoinj.evolution.SimplifiedMasternodeListEntry;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.net.InetSocketAddress;%0Aimport java.net.UnknownHostException;%0Aimport java.util.ArrayList;%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * Created by hashengineering on 12/5/18.%0A */%0Apublic class MasternodePeerDiscovery implements PeerDiscovery %7B%0A%0A    ArrayList%3CInetSocketAddress%3E masternodeSeeds;%0A    private int pnseedIndex;%0A%0A    /**%0A     * Supports finding peers by IP addresses%0A     *%0A     * @param mnList IP addresses for seed addresses.%0A     */%0A    public MasternodePeerDiscovery(SimplifiedMasternodeList mnList) %7B%0A        masternodeSeeds = new ArrayList%3CInetSocketAddress%3E(mnList.size());%0A        mnList.forEachMN(true, new SimplifiedMasternodeList.ForeachMNCallback() %7B%0A            @Override%0A            public void processMN(SimplifiedMasternodeListEntry mn) %7B%0A                masternodeSeeds.add(mn.getService().toSocketAddress());%0A            %7D%0A        %7D);%0A    %7D%0A%0A    /**%0A     * Acts as an iterator, returning the address of each node in the list sequentially.%0A     * Once all the list has been iterated, null will be returned for each subsequent query.%0A     *%0A     * @return InetSocketAddress - The address/port of the next node.%0A     * @throws PeerDiscoveryException%0A     */%0A    @Nullable%0A    public InetSocketAddress getPeer() throws PeerDiscoveryException %7B%0A        try %7B%0A            return nextPeer();%0A        %7D catch (UnknownHostException e) %7B%0A            throw new PeerDiscoveryException(e);%0A        %7D%0A    %7D%0A%0A    @Nullable%0A    private InetSocketAddress nextPeer() throws UnknownHostException, PeerDiscoveryException %7B%0A        if (masternodeSeeds == null %7C%7C masternodeSeeds.isEmpty())%0A            throw new PeerDiscoveryException(%22No masternodes seeds configured; unable to find any peers%22);%0A%0A        if (pnseedIndex %3E= masternodeSeeds.size()) return null;%0A        return masternodeSeeds.get(pnseedIndex++);%0A    %7D%0A%0A    /**%0A     * Returns an array containing all the Dash nodes within the list.%0A     */%0A    @Override%0A    public InetSocketAddress%5B%5D getPeers(long services, long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException %7B%0A        if (services != 0)%0A            throw new PeerDiscoveryException(%22Pre-determined peers cannot be filtered by services: %22 + services);%0A        try %7B%0A            return allPeers();%0A        %7D catch (UnknownHostException e) %7B%0A            throw new PeerDiscoveryException(e);%0A        %7D%0A    %7D%0A%0A    private InetSocketAddress%5B%5D allPeers() throws UnknownHostException %7B%0A        return masternodeSeeds.toArray(new InetSocketAddress%5B0%5D);%0A    %7D%0A%0A    @Override%0A    public void shutdown() %7B%0A    %7D%0A%7D%0A

Add PeerDiscovery for getting peers from a simplified masternode list