liquidnet

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: Apache-2.0 Imports: 37 Imported by: 0

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 = "/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 InitLogger

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

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.

func (*LiquidNet) AddSeed

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

AddSeed add a seed node addr.

func (*LiquidNet) AddTrustRoot

func (l *LiquidNet) AddTrustRoot(chainId string, rootCertByte []byte) error

AddTrustRoot add a tls root cert to the cert pool of chain.

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

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.

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.

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) 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.

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.

func (*LiquidNet) PubSubConfig

func (l *LiquidNet) PubSubConfig() *pubSubConfig

PubSubConfig is the configuration of liquid host.

func (*LiquidNet) ReVerifyTrustRoots

func (l *LiquidNet) ReVerifyTrustRoots(chainId string)

ReVerifyTrustRoots will verify tls certs existed with the trust roots pool of the chain which id is the given chainId.

func (*LiquidNet) RefreshSeeds

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

RefreshSeeds refresh the seed node addr list.

func (*LiquidNet) RefreshTrustRoots

func (l *LiquidNet) RefreshTrustRoots(chainId string, rootsCertsBytes [][]byte) error

RefreshTrustRoots refresh the cert pool of chain.

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.

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.

func (*LiquidNet) Start

func (l *LiquidNet) Start() error

Start the local net.

func (*LiquidNet) Stop

func (l *LiquidNet) Stop() error

Stop the local net.

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.

Jump to

Keyboard shortcuts

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