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 void
broadcast(Message out)
Broadcast messagestatic Network
build(ConfigOption configOption, MsgHandler handler)
Init network modulejava.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
-
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
-