Documentation
¶
Overview ¶
Package relay is instance about relay.
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 ¶
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 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 is insecurity
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 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.
type RelayConfig ¶
type RelayConfig struct {
NetConfig NetConfig `mapstructure:"net"` // net config
}
RelayConfig .
func LoadRelayCfg ¶
func LoadRelayCfg(configPath string) (*RelayConfig, error)
LoadRelayCfg load relay config file
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 create a relay service instance