Documentation ¶
Index ¶
- Variables
- func CreateFlagWithPrefixAndMsgType(prefix string, msgType netPb.NetMsg_MsgType) string
- func CreateMsgHandlerForMsgBus(netService *NetService, topic msgbus.Topic, logMsgDescription string, ...) func(chainId string, node string, data []byte) error
- func HandleMsgBusSubscriberOnMessage(netService *NetService, msgType netPb.NetMsg_MsgType, logMsgDescription string, ...) error
- func NewNetMsg(msg []byte, msgType netPb.NetMsg_MsgType, to string) *netPb.NetMsg
- type ConfigWatcher
- type ConsensusMsgSubscriber
- type ConsistentMsgSubscriber
- type MsgForMsgBusHandler
- type NetContractEventSubscribe
- type NetFactory
- type NetOption
- func WithBlackAddresses(blackAddresses ...string) NetOption
- func WithBlackNodeIds(blackNodeIds ...string) NetOption
- func WithCrypto(pkMode bool, keyFile string, certFile string) NetOption
- func WithInsecurity(isInsecurity bool) NetOption
- func WithListenAddr(addr string) NetOption
- func WithMaxConnCountAllowed(max int) NetOption
- func WithMaxPeerCountAllowed(max int) NetOption
- func WithMsgCompression(enable bool) NetOption
- func WithPeerEliminationStrategy(strategy int) NetOption
- func WithPeerStreamPoolSize(size int) NetOption
- func WithPktEnable(pktEnable bool) NetOption
- func WithPriorityControlEnable(priorityCtrlEnable bool) NetOption
- func WithPubSubMaxMessageSize(size int) NetOption
- func WithReadySignalC(signalC chan struct{}) NetOption
- func WithSeeds(seeds ...string) NetOption
- type NetService
- func (ns *NetService) Apply(opts ...NetServiceOption) error
- func (ns *NetService) BroadcastMsg(msg []byte, msgType netPb.NetMsg_MsgType) error
- func (ns *NetService) CancelConsensusSubscribe(msgType netPb.NetMsg_MsgType) error
- func (ns *NetService) CancelReceiveMsg(msgType netPb.NetMsg_MsgType) error
- func (ns *NetService) CancelSubscribe(msgType netPb.NetMsg_MsgType) error
- func (ns *NetService) ConfigWatcher() protocol.Watcher
- func (ns *NetService) ConsensusBroadcastMsg(msg []byte, msgType netPb.NetMsg_MsgType) error
- func (ns *NetService) ConsensusSubscribe(msgType netPb.NetMsg_MsgType, handler protocol.MsgHandler) error
- func (ns *NetService) GetChainNodesInfo() ([]*protocol.ChainNodeInfo, error)
- func (ns *NetService) GetChainNodesInfoProvider() protocol.ChainNodesInfoProvider
- func (ns *NetService) GetNodeUidByCertId(certId string) (string, error)
- func (ns *NetService) NetConfigSubscribe() msgbus.Subscriber
- func (ns *NetService) ReceiveMsg(msgType netPb.NetMsg_MsgType, handler protocol.MsgHandler) error
- func (ns *NetService) SendMsg(msg []byte, msgType netPb.NetMsg_MsgType, to ...string) error
- func (ns *NetService) Start() error
- func (ns *NetService) Stop() error
- func (ns *NetService) Subscribe(msgType netPb.NetMsg_MsgType, handler protocol.MsgHandler) error
- func (ns *NetService) VmWatcher() protocol.VmWatcher
- type NetServiceFactory
- type NetServiceOption
- type SyncBlockMsgSubscriber
- type TxPoolMsgSubscriber
- type VmWatcher
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorChainMsgBusBeenBound chain msg bus has been bound ErrorChainMsgBusBeenBound = errors.New("chain msg bus has been bound") // ErrorNetNotRunning net instance is not running ErrorNetNotRunning = errors.New("net instance is not running") )
ErrorNetType error net type
var GlobalNetLogger protocol.Logger
GlobalNetLogger protocol.Logger
Functions ¶
func CreateFlagWithPrefixAndMsgType ¶
func CreateFlagWithPrefixAndMsgType(prefix string, msgType netPb.NetMsg_MsgType) string
CreateFlagWithPrefixAndMsgType will join prefix with msg type string.
func CreateMsgHandlerForMsgBus ¶
func CreateMsgHandlerForMsgBus( netService *NetService, topic msgbus.Topic, logMsgDescription string, msgType netPb.NetMsg_MsgType) func(chainId string, node string, data []byte) error
CreateMsgHandlerForMsgBus func
func HandleMsgBusSubscriberOnMessage ¶
func HandleMsgBusSubscriberOnMessage( netService *NetService, msgType netPb.NetMsg_MsgType, logMsgDescription string, message *msgbus.Message) error
HandleMsgBusSubscriberOnMessage is a handler used for msg-bus subscriber OnMessage method.
Types ¶
type ConfigWatcher ¶
type ConfigWatcher struct {
// contains filtered or unexported fields
}
ConfigWatcher is a implementation of protocol.Watcher.
func (*ConfigWatcher) Watch ¶
func (cw *ConfigWatcher) Watch(chainConfig *configPb.ChainConfig) error
Watch ConfigWatcher
type ConsensusMsgSubscriber ¶
type ConsensusMsgSubscriber struct {
// contains filtered or unexported fields
}
ConsensusMsgSubscriber is a subscriber implementation subscribe consensus msg for msgbus.
func (*ConsensusMsgSubscriber) OnMessage ¶
func (cms *ConsensusMsgSubscriber) OnMessage(message *msgbus.Message)
OnMessage ConsensusMsgSubscriber
func (*ConsensusMsgSubscriber) OnQuit ¶
func (cms *ConsensusMsgSubscriber) OnQuit()
OnQuit ConsensusMsgSubscriber
type ConsistentMsgSubscriber ¶
type ConsistentMsgSubscriber struct {
// contains filtered or unexported fields
}
ConsistentMsgSubscriber is a subscriber implementation subscribe consistent msg for msgbus.
func (*ConsistentMsgSubscriber) OnMessage ¶
func (cms *ConsistentMsgSubscriber) OnMessage(message *msgbus.Message)
OnMessage ConsistentMsgSubscriber
func (*ConsistentMsgSubscriber) OnQuit ¶
func (cms *ConsistentMsgSubscriber) OnQuit()
OnQuit ConsistentMsgSubscriber
type MsgForMsgBusHandler ¶
MsgForMsgBusHandler is a handler function that receive the msg from net than publish to msg-bus.
type NetContractEventSubscribe ¶
type NetContractEventSubscribe struct {
// contains filtered or unexported fields
}
NetContractEventSubscribe is a implementation of msgbus.Subscriber
func (*NetContractEventSubscribe) OnMessage ¶
func (n *NetContractEventSubscribe) OnMessage(msg *msgbus.Message)
OnMessage on message
func (*NetContractEventSubscribe) OnQuit ¶
func (n *NetContractEventSubscribe) OnQuit()
OnQuit on quit
type NetFactory ¶
type NetFactory struct {
// contains filtered or unexported fields
}
NetFactory provide a way to create net instance.
func (*NetFactory) NewNet ¶
func (nf *NetFactory) NewNet(netType protocol.NetType, opts ...NetOption) (protocol.Net, error)
NewNet create a new net instance.
type NetOption ¶
type NetOption func(cfg *NetFactory) error
NetOption is a function apply options to net instance.
func WithBlackAddresses ¶
WithBlackAddresses set addresses of the build for blacklist.
func WithBlackNodeIds ¶
WithBlackNodeIds set ids of the build for blacklist.
func WithCrypto ¶
WithCrypto set private key file and tls cert file for the net to create connection.
func WithListenAddr ¶
WithListenAddr set addr that the local net will listen on.
func WithMaxConnCountAllowed ¶
WithMaxConnCountAllowed set max count of connections for each peer that connected to us.
func WithMaxPeerCountAllowed ¶
WithMaxPeerCountAllowed set max count of build that connected to us.
func WithMsgCompression ¶
WithMsgCompression set whether compressing the payload when sending msg.
func WithPeerEliminationStrategy ¶
WithPeerEliminationStrategy set the strategy for eliminating node when the count of build that connected to us reach the max value.
func WithPeerStreamPoolSize ¶
WithPeerStreamPoolSize set the max stream pool size for every node that connected to us.
func WithPriorityControlEnable ¶
WithPriorityControlEnable config priority controller
func WithPubSubMaxMessageSize ¶
WithPubSubMaxMessageSize set max message size (M) for pub/sub.
type NetService ¶
type NetService struct {
// contains filtered or unexported fields
}
NetService provide a net service for modules.
func NewNetService ¶
func NewNetService(chainId string, localNet protocol.Net, ac protocol.AccessControlProvider) *NetService
NewNetService create a new net service instance.
func (*NetService) Apply ¶
func (ns *NetService) Apply(opts ...NetServiceOption) error
Apply the net service options given.
func (*NetService) BroadcastMsg ¶
func (ns *NetService) BroadcastMsg(msg []byte, msgType netPb.NetMsg_MsgType) error
BroadcastMsg broadcast a net msg to other nodes belongs to the same chain.
func (*NetService) CancelConsensusSubscribe ¶
func (ns *NetService) CancelConsensusSubscribe(msgType netPb.NetMsg_MsgType) error
CancelConsensusSubscribe stop receiving the msg which type is the given netPb.NetMsg_MsgType that be broadcast with ConsensusBroadcastMsg method by the other consensus node.
func (*NetService) CancelReceiveMsg ¶ added in v2.3.4
func (ns *NetService) CancelReceiveMsg(msgType netPb.NetMsg_MsgType) error
CancelReceiveMsg cancel receive message
func (*NetService) CancelSubscribe ¶
func (ns *NetService) CancelSubscribe(msgType netPb.NetMsg_MsgType) error
CancelSubscribe stop receiving the msg from the pub-sub topic subscribed.
func (*NetService) ConfigWatcher ¶
func (ns *NetService) ConfigWatcher() protocol.Watcher
ConfigWatcher return a implementation of protocol.Watcher. It is used for refreshing the config.
func (*NetService) ConsensusBroadcastMsg ¶
func (ns *NetService) ConsensusBroadcastMsg(msg []byte, msgType netPb.NetMsg_MsgType) error
ConsensusBroadcastMsg only broadcast a net msg to other consensus nodes belongs to the same chain.
func (*NetService) ConsensusSubscribe ¶
func (ns *NetService) ConsensusSubscribe(msgType netPb.NetMsg_MsgType, handler protocol.MsgHandler) error
ConsensusSubscribe create a listener for receiving the msg which type is the given netPb.NetMsg_MsgType that be broadcast with ConsensusBroadcastMsg method by the other consensus node.
func (*NetService) GetChainNodesInfo ¶
func (ns *NetService) GetChainNodesInfo() ([]*protocol.ChainNodeInfo, error)
GetChainNodesInfo return the base info of the nodes connected.
func (*NetService) GetChainNodesInfoProvider ¶
func (ns *NetService) GetChainNodesInfoProvider() protocol.ChainNodesInfoProvider
GetChainNodesInfoProvider return a protocol.ChainNodesInfoProvider.
func (*NetService) GetNodeUidByCertId ¶
func (ns *NetService) GetNodeUidByCertId(certId string) (string, error)
GetNodeUidByCertId return the id of the node connected to us which mapped to tls cert id given. node id and tls cert id relation will be mapped after connection created success.
func (*NetService) NetConfigSubscribe ¶
func (ns *NetService) NetConfigSubscribe() msgbus.Subscriber
NetConfigSubscribe ConfigWatcher return a implementation of protocol.Watcher. It is used for refreshing the config.
func (*NetService) ReceiveMsg ¶
func (ns *NetService) ReceiveMsg(msgType netPb.NetMsg_MsgType, handler protocol.MsgHandler) error
ReceiveMsg create a listener for receiving the msg which type is the given netPb.NetMsg_MsgType that be sent with ConsensusBroadcastMsg method by the other consensus node.
func (*NetService) SendMsg ¶
func (ns *NetService) SendMsg(msg []byte, msgType netPb.NetMsg_MsgType, to ...string) error
SendMsg send a net msg to the nodes which node ids are the given strings.
func (*NetService) Subscribe ¶
func (ns *NetService) Subscribe(msgType netPb.NetMsg_MsgType, handler protocol.MsgHandler) error
Subscribe a pub-sub topic for receiving the msg that be broadcast by the other node.
func (*NetService) VmWatcher ¶
func (ns *NetService) VmWatcher() protocol.VmWatcher
VmWatcher return an implementation of protocol.VmWatcher. It is used for refreshing revoked peer which use revoked tls cert.
type NetServiceFactory ¶
type NetServiceFactory struct { }
NetServiceFactory is a net service instance factory.
func (*NetServiceFactory) NewNetService ¶
func (nsf *NetServiceFactory) NewNetService( net protocol.Net, chainId string, ac protocol.AccessControlProvider, chainConf protocol.ChainConf, opts ...NetServiceOption) (protocol.NetService, error)
NewNetService create a new net service instance.
type NetServiceOption ¶
type NetServiceOption func(ns *NetService) error
NetServiceOption is a net service option.
func WithConsensusNodeUid ¶
func WithConsensusNodeUid(consensusNodeUid ...string) NetServiceOption
WithConsensusNodeUid set the consensus node id list for net service. This list will be used for broadcast consensus msg to consensus build.
func WithMsgBus ¶
func WithMsgBus(msgBus msgbus.MessageBus) NetServiceOption
WithMsgBus set msg-bus.
type SyncBlockMsgSubscriber ¶
type SyncBlockMsgSubscriber struct {
// contains filtered or unexported fields
}
SyncBlockMsgSubscriber is a subscriber implementation subscribe sync block msg for msgbus.
func (*SyncBlockMsgSubscriber) OnMessage ¶
func (cms *SyncBlockMsgSubscriber) OnMessage(message *msgbus.Message)
OnMessage SyncBlockMsgSubscriber
func (*SyncBlockMsgSubscriber) OnQuit ¶
func (cms *SyncBlockMsgSubscriber) OnQuit()
OnQuit SyncBlockMsgSubscriber
type TxPoolMsgSubscriber ¶
type TxPoolMsgSubscriber struct {
// contains filtered or unexported fields
}
TxPoolMsgSubscriber is a subscriber implementation subscribe tx pool msg for msgbus.
func (*TxPoolMsgSubscriber) OnMessage ¶
func (cms *TxPoolMsgSubscriber) OnMessage(message *msgbus.Message)
OnMessage TxPoolMsgSubscriber
func (*TxPoolMsgSubscriber) OnQuit ¶
func (cms *TxPoolMsgSubscriber) OnQuit()
OnQuit TxPoolMsgSubscriber