liquidnet

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 34 Imported by: 4

Documentation

Index

Constants

View Source
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)
)
View Source
const (
	// NetProtocolTemplatePrefix .
	NetProtocolTemplatePrefix = "/net/v0.0.1/chain-"
)

Variables

View Source
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

func CreateProtocolIdWithChainIdAndMsgFlag(chainId, msgFlag string) protocol.ID

CreateProtocolIdWithChainIdAndMsgFlag create a protocol.ID with the chain id and the msg flag given.

func GenMaAddr added in v1.1.0

func GenMaAddr(addr string) ma.Multiaddr

GenMaAddr converts an address in the form of a string to a multi address object

func InitLogger

func InitLogger(globalNetLogger api.Logger, pubSubLogCreator func(chainId string) api.Logger)

InitLogger .

func LoadChainIdAndFlagWithProtocolId

func LoadChainIdAndFlagWithProtocolId(protocolId protocol.ID) (string, string, error)

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

func NewLiquidNet() (*LiquidNet, error)

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. AddAC . @Description: @receiver l @param chainId @param ac

func (*LiquidNet) AddSeed

func (l *LiquidNet) AddSeed(seed string) error

AddSeed add a seed node addr. AddSeed . @Description: @receiver l @param seed @return error

func (*LiquidNet) BroadcastWithChainId

func (l *LiquidNet) BroadcastWithChainId(chainId string, topic string, data []byte) error

BroadcastWithChainId publish the message to topic, if not subscribe the topic, will return error BroadcastWithChainId . @Description: @receiver l @param chainId @param topic @param data @return error

func (*LiquidNet) CancelDirectMsgHandle

func (l *LiquidNet) CancelDirectMsgHandle(chainId string, msgFlag string) error

CancelDirectMsgHandle unregister a DirectMsgHandler.

msgFlag: is a flag used to distinguish msg type.

CancelDirectMsgHandle . @Description: @receiver l @param chainId @param msgFlag @return error

func (*LiquidNet) CancelSubscribeWithChainId

func (l *LiquidNet) CancelSubscribeWithChainId(chainId string, topic string) error

CancelSubscribeWithChainId cancel subscribe a PubSubTopic with the pub-sub service which id is given chainId. CancelSubscribeWithChainId . @Description: @receiver l @param chainId @param topic @return error

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. ChainNodesInfo . @Description: @receiver l @param chainId @return []*api.ChainNodeInfo @return error

func (*LiquidNet) CryptoConfig

func (l *LiquidNet) CryptoConfig() *cryptoConfig

CryptoConfig is the configuration for crypto.

func (*LiquidNet) DeleteAC added in v1.1.2

func (l *LiquidNet) DeleteAC(chainId string)

DeleteAC delete the AccessControlProvider for revoked validator. DeleteAC . @Description: @receiver l @param chainId

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.

DirectMsgHandle . @Description: @receiver l @param chainId @param msgFlag @param handler @return error

func (*LiquidNet) ExtensionsConfig

func (l *LiquidNet) ExtensionsConfig() *extensionsConfig

ExtensionsConfig is the configuration for extensions.

func (*LiquidNet) GetNodeUid

func (l *LiquidNet) GetNodeUid() string

GetNodeUid get self peer id

func (*LiquidNet) GetNodeUidByCertId

func (l *LiquidNet) GetNodeUidByCertId(certId string) (string, error)

GetNodeUidByCertId return node uid which mapped to the given cert id. If unmapped return error. GetNodeUidByCertId . @Description: @receiver l @param certId @return string @return error

func (*LiquidNet) HolePunch added in v1.1.0

func (l *LiquidNet) HolePunch(pid peer.ID, addr ma.Multiaddr) error

HolePunch try hole punch HolePunch . @Description: @receiver l @param pid @param addr @return error

func (*LiquidNet) HolePunchConfig added in v1.1.0

func (l *LiquidNet) HolePunchConfig() *holePunchConfig

HolePunchConfig is the configuration for extensions.

func (*LiquidNet) HostConfig

func (l *LiquidNet) HostConfig() *lHost.HostConfig

HostConfig is the configuration of liquid host.

func (*LiquidNet) InitPubSub

func (l *LiquidNet) InitPubSub(chainId string, maxMessageSize int) error

InitPubSub will init new PubSub instance with given chainId and maxMessageSize.

func (*LiquidNet) IsRunning

func (l *LiquidNet) IsRunning() bool

IsRunning return true when the net instance is running. IsRunning . @Description: @receiver l @return bool

func (*LiquidNet) PubSubConfig

func (l *LiquidNet) PubSubConfig() *pubSubConfig

PubSubConfig is the configuration of liquid host.

func (*LiquidNet) ReVerifyPeers

func (l *LiquidNet) ReVerifyPeers(chainId string)

ReVerifyPeers will verify permission of peers existed with the access control module of the chain which id is the given chainId. ReVerifyPeers . @Description: @receiver l @param chainId

func (*LiquidNet) RefreshSeeds

func (l *LiquidNet) RefreshSeeds(seeds []string) error

RefreshSeeds refresh the seed node addr list. RefreshSeeds . @Description: @receiver l @param seeds @return error

func (*LiquidNet) SendMsg

func (l *LiquidNet) SendMsg(chainId string, targetPeer string, msgFlag string, data []byte) error

SendMsg send msg to the node which id is given string.

msgFlag: is a flag used to distinguish msg type.

SendMsg . @Description: @receiver l @param chainId @param targetPeer @param msgFlag @param data @return error

func (*LiquidNet) SetChainCustomTrustRoots

func (l *LiquidNet) SetChainCustomTrustRoots(chainId string, roots [][]byte)

SetChainCustomTrustRoots set custom trust roots of chain. In cert permission mode, if it is failed when verifying cert by access control of chains, the cert will be verified by custom trust root pool again. SetChainCustomTrustRoots . @Description: @receiver l @param chainId @param roots

func (*LiquidNet) SetMsgPriority

func (l *LiquidNet) SetMsgPriority(msgFlag string, priority uint8)

SetMsgPriority set the priority of the msg flag. If priority control disabled, it is no-op. SetMsgPriority . @Description: @receiver l @param msgFlag @param priority

func (*LiquidNet) Start

func (l *LiquidNet) Start() error

Start the local net. Start . @Description: @receiver l @return error

func (*LiquidNet) Stop

func (l *LiquidNet) Stop() error

Stop the local net. Stop . @Description: @receiver l @return error

func (*LiquidNet) StopPubSub added in v1.1.2

func (l *LiquidNet) StopPubSub(chainId string)

StopPubSub stop the pubsub by chainId StopPubSub . @Description: @receiver l @param chainId

func (*LiquidNet) StunCheck added in v1.1.0

func (l *LiquidNet) StunCheck(pid peer.ID) (stun.NATDeviceType, stun.NATDeviceType)

StunCheck invoke stun func StunCheck . @Description: @receiver l @param pid @return stun.NATDeviceType @return stun.NATDeviceType

func (*LiquidNet) StunClientConfig added in v1.1.0

func (l *LiquidNet) StunClientConfig() *stunClientConfig

StunClientConfig is the configuration for stun.

func (*LiquidNet) StunServerConfig added in v1.1.0

func (l *LiquidNet) StunServerConfig() *stunServerConfig

StunServerConfig is the configuration for stun.

func (*LiquidNet) SubscribeWithChainId

func (l *LiquidNet) SubscribeWithChainId(chainId string, topic string, handler api.PubSubMsgHandler) error

SubscribeWithChainId register a PubSubMsgHandler to a PubSubTopic with the pub-sub service which id is given chainId. SubscribeWithChainId . @Description: @receiver l @param chainId @param topic @param handler @return error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL