Package org.fisco.bcos.sdk.network
Interface Network
- All Known Implementing Classes:
NetworkImp
public interface Network
Network interface Modules interact with the network module through this interface.
-
Method Summary
Modifier and Type Method Description voidbroadcast(Message out)Broadcast messagestatic Networkbuild(ConfigOption configOption, MsgHandler handler)Init network modulejava.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
-
Method Details
-
build
Init network module- Parameters:
configOption- the path of the yaml config filehandler- message handler- Returns:
- a Network implementation instance
- Throws:
ConfigException- the configuration exception
-
getConfigOption
ConfigOption getConfigOption() -
getSslCryptoType
int getSslCryptoType() -
broadcast
Broadcast message- Parameters:
out- the message to broadcast
-
sendToPeer
Send to peer- Parameters:
out- the sent messagepeerIpPort- 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
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
-