Class MultiplexingDiscovery

  • All Implemented Interfaces:
    PeerDiscovery
    Direct Known Subclasses:
    DnsDiscovery

    public class MultiplexingDiscovery
    extends java.lang.Object
    implements PeerDiscovery
    MultiplexingDiscovery queries multiple PeerDiscovery objects, optionally shuffles their responses and then returns the results, thus selecting randomly between them and reducing the influence of any particular seed. Any that don't respond within the timeout are ignored. Backends are queried in parallel or serially. Backends may block.
    • Constructor Detail

      • MultiplexingDiscovery

        public MultiplexingDiscovery​(NetworkParameters params,
                                     java.util.List<PeerDiscovery> seeds)
        Will query the given seeds in parallel before producing a merged response.
    • Method Detail

      • forServices

        public static MultiplexingDiscovery forServices​(NetworkParameters params,
                                                        long services)
        Builds a suitable set of peer discoveries. Will query them in parallel before producing a merged response.
        Parameters:
        params - Network to use.
        services - Required services as a bitmask, e.g. VersionMessage.NODE_NETWORK.
      • forServices

        public static MultiplexingDiscovery forServices​(NetworkParameters params,
                                                        long services,
                                                        boolean parallelQueries,
                                                        boolean shufflePeers)
        Builds a suitable set of peer discoveries.
        Parameters:
        params - Network to use.
        services - Required services as a bitmask, e.g. VersionMessage.NODE_NETWORK.
        parallelQueries - When true, seeds are queried in parallel
        shufflePeers - When true, queried peers are shuffled
      • createExecutor

        protected java.util.concurrent.ExecutorService createExecutor()
      • shutdown

        public void shutdown()
        Description copied from interface: PeerDiscovery
        Stops any discovery in progress when we want to shut down quickly.
        Specified by:
        shutdown in interface PeerDiscovery