public ListenableFuture<List<Peer>> waitForPeersOfVersion(final int numPeers, final long protocolVersion) {
        List<Peer> foundPeers = findPeersOfAtLeastVersion(protocolVersion);
        if (foundPeers.size() >= numPeers) {
            return Futures.immediateFuture(foundPeers);
        }
        final SettableFuture<List<Peer>> future = SettableFuture.create();
        addConnectedEventListener(new PeerConnectedEventListener() {
            @Override
            public void onPeerConnected(Peer peer, int peerCount) {
                final List<Peer> peers = findPeersOfAtLeastVersion(protocolVersion);
                if (peers.size() >= numPeers) {
                    future.set(peers);
                    removeConnectedEventListener(this);
                }
            }
        });
        return future;
    }
public ListenableFuture < List < Peer > > waitForPeersOfVersion ( final int numPeers , final long protocolVersion ) { List < Peer > foundPeers = findPeersOfAtLeastVersion ( protocolVersion ) ; if ( foundPeers . size ( ) >= numPeers ) { return Futures . immediateFuture ( foundPeers ) ; } final SettableFuture < List < Peer > > future = SettableFuture . create ( ) ; addConnectedEventListener ( new PeerConnectedEventListener ( ) { @ Override public void onPeerConnected ( Peer peer , int peerCount ) { final List < Peer > peers = findPeersOfAtLeastVersion ( protocolVersion ) ; if ( peers . size ( ) >= numPeers ) { future . set ( peers ) ; removeConnectedEventListener ( this ) ; } } } ) ; return future ; }
Returns a future that is triggered when there are at least the requested number of connected peers that support
the given protocol version or higher. To block immediately, just call get() on the result.

@param numPeers How many peers to wait for.
@param protocolVersion The protocol version the awaited peers must implement (or better).
@return a future that will be triggered when the number of connected peers implementing protocolVersion or higher is greater than or equals numPeers