Class BlockingClientManager

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service

        com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State
    • Constructor Summary

      Constructors 
      Constructor Description
      BlockingClientManager()  
      BlockingClientManager​(javax.net.SocketFactory socketFactory)
      Creates a blocking client manager that will obtain sockets from the given factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void closeConnections​(int n)
      Closes n peer connections
      int getConnectedClientCount()
      Gets the number of connected peers
      ListenableCompletableFuture<java.net.SocketAddress> openConnection​(java.net.SocketAddress serverAddress, StreamConnection connection)
      Creates a new connection to the given address, with the given connection used to handle incoming data.
      void setConnectTimeout​(java.time.Duration connectTimeout)
      Sets the number of milliseconds to wait before giving up on a connect attempt
      void setConnectTimeoutMillis​(int connectTimeoutMillis)
      protected void shutDown()  
      protected void startUp()  
      • Methods inherited from class com.google.common.util.concurrent.AbstractIdleService

        addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.google.common.util.concurrent.Service

        addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
    • Constructor Detail

      • BlockingClientManager

        public BlockingClientManager()
      • BlockingClientManager

        public BlockingClientManager​(javax.net.SocketFactory socketFactory)
        Creates a blocking client manager that will obtain sockets from the given factory. Useful for customising how bitcoinj connects to the P2P network.
    • Method Detail

      • openConnection

        public ListenableCompletableFuture<java.net.SocketAddress> openConnection​(java.net.SocketAddress serverAddress,
                                                                                  StreamConnection connection)
        Description copied from interface: ClientConnectionManager
        Creates a new connection to the given address, with the given connection used to handle incoming data. Any errors that occur during connection will be returned in the given future, including errors that can occur immediately.
        Specified by:
        openConnection in interface ClientConnectionManager
      • setConnectTimeout

        public void setConnectTimeout​(java.time.Duration connectTimeout)
        Sets the number of milliseconds to wait before giving up on a connect attempt
        Parameters:
        connectTimeout - timeout for establishing a connection to the client
      • setConnectTimeoutMillis

        @Deprecated
        public void setConnectTimeoutMillis​(int connectTimeoutMillis)
      • startUp

        protected void startUp()
                        throws java.lang.Exception
        Specified by:
        startUp in class com.google.common.util.concurrent.AbstractIdleService
        Throws:
        java.lang.Exception
      • shutDown

        protected void shutDown()
                         throws java.lang.Exception
        Specified by:
        shutDown in class com.google.common.util.concurrent.AbstractIdleService
        Throws:
        java.lang.Exception