Documentation ¶
Index ¶
- func CreateP2PNet(chanName string) (nodeNetwork *libp2pnet.LibP2pNet, err error)
- func SendMsg(chanName string, node *libp2pnet.LibP2pNet, msg *Message, receiveId string) (err error)
- func SetHandler(chanName string, nodeNetwork *libp2pnet.LibP2pNet, nodeName string) (err error)
- type Message
- type MsgType
- 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 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
- func WithTrustRoots(chainId string, caFiles ...string) NetOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateP2PNet ¶
CreateP2PNet use channel name create p2pnet
Types ¶
type Message ¶
Message define message struct
type MsgType ¶
type MsgType int32
MsgType message type
const ( // HBPing heart beat message type HBPing MsgType = iota // NodeJoin node join message type NodeJoin // NodeJoinResp node join response message type NodeJoinResp // NodeExit node exit message type NodeExit // NodePubkeySync node pub key sync message type NodePubkeySync // TxMsg tx message message type TxMsg // TxRequest tx request message type TxRequest // TxCommit tx commit message type TxCommit // TxNotify tx notify message type TxNotify // UpdateStateRequest update state request message type UpdateStateRequest // UpdateStateReply update state reply message type UpdateStateReply // UpdateStateConfirm update state confirm message type UpdateStateConfirm // TradePhaseNotify trade phase notify message type TradePhaseNotify // ConsensusPhaseNotify consensus phase notify message type ConsensusPhaseNotify )
type NetOption ¶
NetOption is a function apply options to net instance.
func WithBlackAddresses ¶
WithBlackAddresses set addresses of the nodes for blacklist.
func WithBlackNodeIds ¶
WithBlackNodeIds set ids of the nodes for blacklist.
func WithCrypto ¶
WithCrypto set private key file and tls cert file for the net to create connection.
func WithInsecurity ¶
WithInsecurity set insecurity p2p
func WithListenAddr ¶
WithListenAddr set addr that the local net will listen on.
func WithMaxPeerCountAllowed ¶
WithMaxPeerCountAllowed set max count of nodes 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 nodes 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.
func WithReadySignalC ¶
func WithReadySignalC(signalC chan struct{}) NetOption
WithReadySignalC set a ready flag
func WithSeeds ¶
WithSeeds set addresses of discovery service node.