code: public ListenableFuture<List<Peer>> waitForPeersWithServiceMask(final int numPeers, final int mask) {
          lock.lock();
          try {
              List<Peer> foundPeers = findPeersWithServiceMask(mask);
              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 = findPeersWithServiceMask(mask);
                      if (peers.size() >= numPeers) {
                          future.set(peers);
                          removeConnectedEventListener(this);
                      }
                  }
              });
              return future;
          } finally {
              lock.unlock();
          }
      }
docs: 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 mask An integer representing a bit mask that will be ANDed with the peers advertised service masks.
  @return a future that will be triggered when the number of connected peers implementing protocolVersion or higher is greater than or equals numPeers