Interface Network

All Known Implementing Classes:
NetworkImp

public interface Network
Network interface Modules interact with the network module through this interface.
  • Method Details

    • build

      static Network build​(ConfigOption configOption, MsgHandler handler) throws ConfigException
      Init network module
      Parameters:
      configOption - the path of the yaml config file
      handler - message handler
      Returns:
      a Network implementation instance
      Throws:
      ConfigException - the configuration exception
    • getConfigOption

      ConfigOption getConfigOption()
    • getSslCryptoType

      int getSslCryptoType()
    • broadcast

      void broadcast​(Message out)
      Broadcast message
      Parameters:
      out - the message to broadcast
    • sendToPeer

      void sendToPeer​(Message out, java.lang.String peerIpPort) throws NetworkException
      Send to peer
      Parameters:
      out - the sent message
      peerIpPort - the node to receive the message
      Throws:
      NetworkException - the network exception
    • getConnectionInfo

      java.util.List<ConnectionInfo> getConnectionInfo()
      Get connection information
      Returns:
      list of connection information
    • start

      void start() throws NetworkException
      Start connect peers
      Throws:
      NetworkException - start the network exceptioned
    • getAvailableConnections

      java.util.Map<java.lang.String,​io.netty.channel.ChannelHandlerContext> getAvailableConnections()
      Get available connection context
      Returns:
      the map between the peer endpoint and the channelHandlerContext
    • removeConnection

      void removeConnection​(java.lang.String peerIpPort)
      Remove the connection if version negotiation failed
      Parameters:
      peerIpPort - the peer connection to be removed
    • setMsgHandleThreadPool

      void setMsgHandleThreadPool​(java.util.concurrent.ExecutorService threadPool)
      Set thread pool
      Parameters:
      threadPool - the threadpool to handle the network message
    • stop

      void stop()
      Exit gracefully