Package org.fisco.bcos.sdk.network
Class NetworkImp
java.lang.Object
org.fisco.bcos.sdk.network.NetworkImp
- All Implemented Interfaces:
Network
public class NetworkImp extends java.lang.Object implements Network
An implementation of Network
-
Constructor Summary
Constructors Constructor Description NetworkImp(ConfigOption configOption, MsgHandler handler)
-
Method Summary
Modifier and Type Method Description void
broadcast(Message out)
Broadcast messagejava.util.Map<java.lang.String,io.netty.channel.ChannelHandlerContext>
getAvailableConnections()
Get available connection contextConfigOption
getConfigOption()
java.util.List<ConnectionInfo>
getConnectionInfo()
Get connection informationint
getSslCryptoType()
void
removeConnection(java.lang.String peerIpPort)
Remove the connection if version negotiation failedvoid
sendToPeer(Message out, java.lang.String peerIpPort)
Send to peervoid
setMsgHandleThreadPool(java.util.concurrent.ExecutorService threadPool)
Set thread poolvoid
start()
Start connect peersvoid
stop()
Exit gracefully
-
Constructor Details
-
NetworkImp
- Throws:
ConfigException
-
-
Method Details
-
getConfigOption
- Specified by:
getConfigOption
in interfaceNetwork
-
getSslCryptoType
public int getSslCryptoType()- Specified by:
getSslCryptoType
in interfaceNetwork
-
broadcast
Description copied from interface:Network
Broadcast message -
sendToPeer
Description copied from interface:Network
Send to peer- Specified by:
sendToPeer
in interfaceNetwork
- Parameters:
out
- the sent messagepeerIpPort
- the node to receive the message- Throws:
NetworkException
- the network exception
-
getConnectionInfo
Description copied from interface:Network
Get connection information- Specified by:
getConnectionInfo
in interfaceNetwork
- Returns:
- list of connection information
-
start
Description copied from interface:Network
Start connect peers- Specified by:
start
in interfaceNetwork
- Throws:
NetworkException
- start the network exceptioned
-
getAvailableConnections
public java.util.Map<java.lang.String,io.netty.channel.ChannelHandlerContext> getAvailableConnections()Description copied from interface:Network
Get available connection context- Specified by:
getAvailableConnections
in interfaceNetwork
- Returns:
- the map between the peer endpoint and the channelHandlerContext
-
removeConnection
public void removeConnection(java.lang.String peerIpPort)Description copied from interface:Network
Remove the connection if version negotiation failed- Specified by:
removeConnection
in interfaceNetwork
- Parameters:
peerIpPort
- the peer connection to be removed
-
setMsgHandleThreadPool
public void setMsgHandleThreadPool(java.util.concurrent.ExecutorService threadPool)Description copied from interface:Network
Set thread pool- Specified by:
setMsgHandleThreadPool
in interfaceNetwork
- Parameters:
threadPool
- the threadpool to handle the network message
-
stop
public void stop()Description copied from interface:Network
Exit gracefully
-