Documentation ¶
Index ¶
- Constants
- Variables
- func CreateProtocolIdWithChainIdAndMsgFlag(chainId, msgFlag string) protocol.ID
- func InitLogger(globalNetLogger api.Logger, pubSubLogCreator func(chainId string) api.Logger)
- func LoadChainIdAndFlagWithProtocolId(protocolId protocol.ID) (string, string, error)
- func SetListenAddrStr(hc *host.HostConfig, listenAddrStr string) error
- type LiquidNet
- func (l *LiquidNet) AddAC(chainId string, ac api.AccessControlProvider)
- func (l *LiquidNet) AddSeed(seed string) error
- func (l *LiquidNet) AddTrustRoot(chainId string, rootCertByte []byte) error
- func (l *LiquidNet) BroadcastWithChainId(chainId string, topic string, data []byte) error
- func (l *LiquidNet) CancelDirectMsgHandle(chainId string, msgFlag string) error
- func (l *LiquidNet) CancelSubscribeWithChainId(chainId string, topic string) error
- func (l *LiquidNet) ChainNodesInfo(chainId string) ([]*api.ChainNodeInfo, error)
- func (l *LiquidNet) CheckRevokeTlsCerts(ac api.AccessControlProvider, certManageSystemContractPayload []byte) error
- func (l *LiquidNet) CryptoConfig() *cryptoConfig
- func (l *LiquidNet) DirectMsgHandle(chainId string, msgFlag string, handler api.DirectMsgHandler) error
- func (l *LiquidNet) ExtensionsConfig() *extensionsConfig
- func (l *LiquidNet) GetNodeUid() string
- func (l *LiquidNet) GetNodeUidByCertId(certId string) (string, error)
- func (l *LiquidNet) HostConfig() *lHost.HostConfig
- func (l *LiquidNet) InitPubSub(chainId string, maxMessageSize int) error
- func (l *LiquidNet) IsRunning() bool
- func (l *LiquidNet) PubSubConfig() *pubSubConfig
- func (l *LiquidNet) ReVerifyTrustRoots(chainId string)
- func (l *LiquidNet) RefreshSeeds(seeds []string) error
- func (l *LiquidNet) RefreshTrustRoots(chainId string, rootsCertsBytes [][]byte) error
- func (l *LiquidNet) SendMsg(chainId string, targetPeer string, msgFlag string, data []byte) error
- func (l *LiquidNet) SetMsgPriority(msgFlag string, priority uint8)
- func (l *LiquidNet) Start() error
- func (l *LiquidNet) Stop() error
- func (l *LiquidNet) SubscribeWithChainId(chainId string, topic string, handler api.PubSubMsgHandler) error
Constants ¶
const ( // DefaultMaxPeerCount is the default value for HostConfig.MaxPeerCountAllowed. DefaultMaxPeerCount = 20 // DefaultMaxConnCountEachPeer is the default value for HostConfig.MaxConnCountEachPeerAllowed. DefaultMaxConnCountEachPeer = 1 // DefaultPeerEliminationStrategy is the default value for HostConfig.ConnEliminationStrategy. DefaultPeerEliminationStrategy = 3 // DefaultInitSendStreamSize is the default value for HostConfig.SendStreamPoolInitSize. DefaultInitSendStreamSize = 10 // DefaultSendStreamMaxCount is the default value for HostConfig.SendStreamPoolCap. DefaultSendStreamMaxCount = 100 // DefaultListenAddress is the default value for HostConfig.ListenAddresses. DefaultListenAddress = "/ip4/0.0.0.0/tcp/0" // DefaultPubSubMaxMessageSize is the default value for pubSubConfig.MaxPubMessageSize. DefaultPubSubMaxMessageSize = 50 * (2 << 20) )
const (
NetProtocolTemplatePrefix = "/net/v0.0.1/chain-"
)
Variables ¶
var ( // ErrorPubSubNotExist will be returned when pub-sub service not exist. ErrorPubSubNotExist = errors.New("pub-sub service not exist") // ErrorPubSubExisted will be returned if the pub-sub service exist // when calling InitPubSub method. ErrorPubSubExisted = errors.New("pub-sub service existed") // ErrorTopicSubscribed will be returned if the topic has been // subscribed when calling SubscribeWithChainId method. ErrorTopicSubscribed = errors.New("topic has been subscribed") // ErrorTopicNotSubscribed will be returned if the topic has // not been subscribed when calling CancelSubscribeWithChainId method. ErrorTopicNotSubscribed = errors.New("topic has not been subscribed") // ErrorNotBelongToChain will be returned if the remote node // not belong to chain expected when calling SendMsg method. ErrorNotBelongToChain = errors.New("node not belong to chain") // ErrorWrongAddressOrUnsupported will be returned if the listening // address is wrong or unsupported when calling Start method. ErrorWrongAddressOrUnsupported = errors.New("wrong address or address unsupported") // ErrorNetRunning will be returned if Start method has been called // when calling Start method. ErrorNetRunning = errors.New("net running") )
Functions ¶
func CreateProtocolIdWithChainIdAndMsgFlag ¶
CreateProtocolIdWithChainIdAndMsgFlag create a protocol.ID with the chain id and the msg flag given.
func InitLogger ¶
func LoadChainIdAndFlagWithProtocolId ¶
LoadChainIdAndFlagWithProtocolId resolves the chain id and the msg flag from a protocol.ID given.
func SetListenAddrStr ¶
func SetListenAddrStr(hc *host.HostConfig, listenAddrStr string) error
SetListenAddrStr set the local address will be listening on fot host.HostConfig.
Types ¶
type LiquidNet ¶
type LiquidNet struct {
// contains filtered or unexported fields
}
LiquidNet is an implementation of Net interface with liquid.
func NewLiquidNet ¶
NewLiquidNet create a new LiquidNet instance.
func (*LiquidNet) AddAC ¶
func (l *LiquidNet) AddAC(chainId string, ac api.AccessControlProvider)
AddAC add a AccessControlProvider for revoked validator.
func (*LiquidNet) AddSeed ¶
AddSeed add a seed node addr.
func (*LiquidNet) AddTrustRoot ¶
AddTrustRoot add a tls root cert to the cert pool of chain.
func (*LiquidNet) BroadcastWithChainId ¶
BroadcastWithChainId publish the message to topic, if not subscribe the topic, will return error
func (*LiquidNet) CancelDirectMsgHandle ¶
CancelDirectMsgHandle unregister a DirectMsgHandler.
msgFlag: is a flag used to distinguish msg type.
func (*LiquidNet) CancelSubscribeWithChainId ¶
CancelSubscribeWithChainId cancel subscribe a PubSubTopic with the pub-sub service which id is given chainId.
func (*LiquidNet) ChainNodesInfo ¶
func (l *LiquidNet) ChainNodesInfo(chainId string) ([]*api.ChainNodeInfo, error)
ChainNodesInfo return base node info list of chain which id is the given chainId.
func (*LiquidNet) CheckRevokeTlsCerts ¶
func (l *LiquidNet) CheckRevokeTlsCerts(ac api.AccessControlProvider, certManageSystemContractPayload []byte) error
CheckRevokeTlsCerts check whether any tls certs revoked.
func (*LiquidNet) CryptoConfig ¶
func (l *LiquidNet) CryptoConfig() *cryptoConfig
CryptoConfig is the configuration for crypto.
func (*LiquidNet) DirectMsgHandle ¶
func (l *LiquidNet) DirectMsgHandle(chainId string, msgFlag string, handler api.DirectMsgHandler) error
DirectMsgHandle register a DirectMsgHandler to the net.
msgFlag: is a flag used to distinguish msg type.
func (*LiquidNet) ExtensionsConfig ¶
func (l *LiquidNet) ExtensionsConfig() *extensionsConfig
ExtensionsConfig is the configuration for extensions.
func (*LiquidNet) GetNodeUidByCertId ¶
GetNodeUidByCertId return node uid which mapped to the given cert id. If unmapped return error.
func (*LiquidNet) HostConfig ¶
func (l *LiquidNet) HostConfig() *lHost.HostConfig
HostConfig is the configuration of liquid host.
func (*LiquidNet) InitPubSub ¶
InitPubSub will init new PubSub instance with given chainId and maxMessageSize.
func (*LiquidNet) IsRunning ¶
IsRunning return true when the net instance is running.
func (*LiquidNet) PubSubConfig ¶
func (l *LiquidNet) PubSubConfig() *pubSubConfig
PubSubConfig is the configuration of liquid host.
func (*LiquidNet) ReVerifyTrustRoots ¶
ReVerifyTrustRoots will verify tls certs existed with the trust roots pool of the chain which id is the given chainId.
func (*LiquidNet) RefreshSeeds ¶
RefreshSeeds refresh the seed node addr list.
func (*LiquidNet) RefreshTrustRoots ¶
RefreshTrustRoots refresh the cert pool of chain.
func (*LiquidNet) SendMsg ¶
SendMsg send msg to the node which id is given string.
msgFlag: is a flag used to distinguish msg type.
func (*LiquidNet) SetMsgPriority ¶
SetMsgPriority set the priority of the msg flag. If priority control disabled, it is no-op.