Documentation ¶
Index ¶
- func Apply(ln *libp2pnet.LibP2pNet, opts ...NetOption) error
- func NewNet(cfg *NetConfig, readySignalC chan struct{}) (protocol.Net, error)
- type CustomTrustRootsConfig
- type NetConfig
- 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 WithPeerEliminationStrategy(strategy int) NetOption
- func WithPeerStreamPoolSize(size int) NetOption
- func WithReadySignalC(signalC chan struct{}) NetOption
- func WithSeeds(seeds ...string) NetOption
- type RelayConfig
- type RelayService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply . @Description: options. @param ln: @param opts: @return error:
Types ¶
type CustomTrustRootsConfig ¶
type CustomTrustRootsConfig struct { ChainId string `mapstructure:"chain_id"` TrustRoots []string `mapstructure:"trust_roots"` }
CustomTrustRootsConfig .
type NetConfig ¶
type NetConfig struct { AuthType string `mapstructure:"auth_type"` ListenAddr string `mapstructure:"listen_addr"` PeerStreamPoolSize int `mapstructure:"peer_stream_pool_size"` MaxPeerCountAllow int `mapstructure:"max_peer_count_allow"` PeerEliminationStrategy int `mapstructure:"peer_elimination_strategy"` // default LIFO Seeds []string `mapstructure:"seeds"` TLSConfig netTlsConfig `mapstructure:"tls"` BlackList blackList `mapstructure:"blacklist"` IsNetInsecurity bool `mapstructure:"is_net_insecurity"` UseNetMsgCompression bool `mapstructure:"use_net_msg_compression"` CustomTrustRootsConfigs []CustomTrustRootsConfig `mapstructure:"custom_trust_roots"` // custom trust root }
NetConfig .
type NetOption ¶
NetOption is a function apply options to net instance.
func WithBlackAddresses ¶
WithBlackAddresses . @Description: set addresses of the nodes for blacklist. @param blackAddresses: @return NetOption:
func WithBlackNodeIds ¶
WithBlackNodeIds . @Description: set ids of the nodes for blacklist. @param blackNodeIds: @return NetOption:
func WithCrypto ¶
WithCrypto . @Description: set private key file and tls cert file for the net to create connection. @param pkMode: @param keyFile: @param certFile: @return NetOption:
func WithInsecurity ¶
WithInsecurity . @Description: set is insecurity @param isInsecurity: @return NetOption:
func WithListenAddr ¶
WithListenAddr . @Description: set addr that the local net will listen on. @param addr: @return NetOption:
func WithMaxPeerCountAllowed ¶
WithMaxPeerCountAllowed . @Description: set max count of nodes that connected to us. @param max: @return NetOption:
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 . @Description: set the max stream pool size for every node that connected to us. @param size: @return NetOption:
type RelayConfig ¶
type RelayConfig struct {
NetConfig NetConfig `mapstructure:"net"` // net config
}
RelayConfig .
func LoadRelayCfg ¶
func LoadRelayCfg(configPath string) (*RelayConfig, error)
LoadRelayCfg . @Description: load relay config file @param configPath: @return *RelayConfig: @return error:
type RelayService ¶
type RelayService struct {
// contains filtered or unexported fields
}
RelayService relay service, provide relay function
func NewRelayService ¶
func NewRelayService(cfg *RelayConfig) (*RelayService, error)
NewRelayService . @Description: create a relay service instance @param cfg: @return *RelayService: @return error:
func (*RelayService) Start ¶
func (rs *RelayService) Start() error
Start . @Description: RelayService start @receiver rs @return error:
func (*RelayService) Stop ¶
func (rs *RelayService) Stop() error
Stop . @Description: RelayService stop @receiver rs @return error: