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 voidbroadcast(Message out)Broadcast messagejava.util.Map<java.lang.String,io.netty.channel.ChannelHandlerContext>getAvailableConnections()Get available connection contextConfigOptiongetConfigOption()java.util.List<ConnectionInfo>getConnectionInfo()Get connection informationintgetSslCryptoType()voidremoveConnection(java.lang.String peerIpPort)Remove the connection if version negotiation failedvoidsendToPeer(Message out, java.lang.String peerIpPort)Send to peervoidsetMsgHandleThreadPool(java.util.concurrent.ExecutorService threadPool)Set thread poolvoidstart()Start connect peersvoidstop()Exit gracefully
-
Constructor Details
-
NetworkImp
- Throws:
ConfigException
-
-
Method Details
-
getConfigOption
- Specified by:
getConfigOptionin interfaceNetwork
-
getSslCryptoType
public int getSslCryptoType()- Specified by:
getSslCryptoTypein interfaceNetwork
-
broadcast
Description copied from interface:NetworkBroadcast message -
sendToPeer
Description copied from interface:NetworkSend to peer- Specified by:
sendToPeerin interfaceNetwork- Parameters:
out- the sent messagepeerIpPort- the node to receive the message- Throws:
NetworkException- the network exception
-
getConnectionInfo
Description copied from interface:NetworkGet connection information- Specified by:
getConnectionInfoin interfaceNetwork- Returns:
- list of connection information
-
start
Description copied from interface:NetworkStart connect peers- Specified by:
startin interfaceNetwork- Throws:
NetworkException- start the network exceptioned
-
getAvailableConnections
public java.util.Map<java.lang.String,io.netty.channel.ChannelHandlerContext> getAvailableConnections()Description copied from interface:NetworkGet available connection context- Specified by:
getAvailableConnectionsin interfaceNetwork- Returns:
- the map between the peer endpoint and the channelHandlerContext
-
removeConnection
public void removeConnection(java.lang.String peerIpPort)Description copied from interface:NetworkRemove the connection if version negotiation failed- Specified by:
removeConnectionin interfaceNetwork- Parameters:
peerIpPort- the peer connection to be removed
-
setMsgHandleThreadPool
public void setMsgHandleThreadPool(java.util.concurrent.ExecutorService threadPool)Description copied from interface:NetworkSet thread pool- Specified by:
setMsgHandleThreadPoolin interfaceNetwork- Parameters:
threadPool- the threadpool to handle the network message
-
stop
public void stop()Description copied from interface:NetworkExit gracefully
-