Versions in this module Expand all Collapse all v1 v1.0.3 Feb 27, 2025 Changes in this version + const DefaultDialRatio + const DefaultEdgeLibp2pPort + const DefaultLibp2pPort + const DefaultRelayLibp2pPort + const MinimumBootNodes + const MinimumPeerConnections + var DefaultBufferTimeout = DefaultJoinTimeout + time.Second*5 + var DefaultJoinTimeout = 100 * time.Second + var ErrMinBootnodes = errors.New("minimum 1 bootnode is required") + var ErrMinRelaynodes = errors.New("minimum 1 relaynode is required") + var ErrNoBootnodes = errors.New("no bootnodes specified") + var ErrNoRelaynodes = errors.New("no relaynodes specified") + func GenerateAndEncodeLibp2pKey() (crypto.PrivKey, []byte, error) + func ParseLibp2pKey(key []byte) (crypto.PrivKey, error) + func ReadLibp2pKey(manager secrets.SecretsManager) (crypto.PrivKey, error) + type Config struct + Addr *net.TCPAddr + DNS multiaddr.Multiaddr + DataDir string + MaxInboundPeers int64 + MaxOutboundPeers int64 + MaxPeers int64 + NatAddr net.IP + NetworkID int64 + NoDiscover bool + SecretsManager secrets.SecretsManager + func DefaultConfig() *Config + type ConnectionInfo struct + func NewBlankConnectionInfo(maxInboundConnCount int64, maxOutboundConnCount int64) *ConnectionInfo + func (ci *ConnectionInfo) GetInboundConnCount() int64 + func (ci *ConnectionInfo) GetOutboundConnCount() int64 + func (ci *ConnectionInfo) GetPendingInboundConnCount() int64 + func (ci *ConnectionInfo) GetPendingOutboundConnCount() int64 + func (ci *ConnectionInfo) HasFreeConnectionSlot(direction network.Direction) bool + func (ci *ConnectionInfo) HasFreeInboundConn() bool + func (ci *ConnectionInfo) HasFreeOutboundConn() bool + func (ci *ConnectionInfo) UpdateConnCountByDirection(delta int64, direction network.Direction) + func (ci *ConnectionInfo) UpdatePendingConnCountByDirection(delta int64, direction network.Direction) + type PeerConnInfo struct + Info peer.AddrInfo + type PeerUpdateInfo struct + From string + Info peer.AddrInfo + PublishTime time.Time + UpdateTime time.Time + type Protocol interface + Client func(network.Stream) *rawGrpc.ClientConn + Handler func() func(network.Stream) + type Server struct + func NewServer(logger hclog.Logger, config *Config, discProto string, identityProto string, ...) (*Server, error) + func (s *Server) AddPeer(id peer.ID, direction network.Direction) + func (s *Server) AddToPeerStore(peerInfo *peer.AddrInfo) + func (s *Server) AddrInfo() *peer.AddrInfo + func (s *Server) Close() error + func (s *Server) CloseProtocolStream(protocol string, peerID peer.ID) error + func (s *Server) DisconnectFromPeer(peer peer.ID, reason string) + func (s *Server) EmitEvent(event *peerEvent.PeerEvent) + func (s *Server) FetchOrSetTemporaryDial(peerID peer.ID, newValue bool) bool + func (s *Server) GetBootnodeConnCount() int64 + func (s *Server) GetDiscProto() string + func (s *Server) GetHost() host.Host + func (s *Server) GetPeerDistance(peerID peer.ID) *big.Int + func (s *Server) GetPeerInfo(peerID peer.ID) *peer.AddrInfo + func (s *Server) GetProtocols(peerID peer.ID) ([]protocol.ID, error) + func (s *Server) GetRandomBootnode() *peer.AddrInfo + func (s *Server) GetRandomPeer() *peer.ID + func (s *Server) HasFreeConnectionSlot(direction network.Direction) bool + func (s *Server) IsConnected(peerID peer.ID) bool + func (s *Server) IsTemporaryDial(peerID peer.ID) bool + func (s *Server) JoinPeer(rawPeerMultiaddr string) error + func (s *Server) NewDiscoveryClient(peerID peer.ID) (proto.DiscoveryClient, error) + func (s *Server) NewIdentityClient(peerID peer.ID) (proto.IdentityClient, error) + func (s *Server) NewProtoConnection(protocol string, peerID peer.ID) (*rawGrpc.ClientConn, error) + func (s *Server) NewStream(proto string, id peer.ID) (network.Stream, error) + func (s *Server) NewTopic(protoID string, obj proto.Message) (*Topic, error) + func (s *Server) Peers() []*PeerConnInfo + func (s *Server) RegisterProtocol(id string, p Protocol) + func (s *Server) RemoveFromPeerStore(peerInfo *peer.AddrInfo) + func (s *Server) RemoveTemporaryDial(peerID peer.ID) + func (s *Server) SaveProtocolStream(protocol string, stream *rawGrpc.ClientConn, peerID peer.ID) + func (s *Server) Start(netName string, bootnodes []string) error + func (s *Server) StartMininum(netName string) error + func (s *Server) Subscribe() (*Subscription, error) + func (s *Server) SubscribeCh(ctx context.Context) (<-chan *peerEvent.PeerEvent, error) + func (s *Server) SubscribeFn(ctx context.Context, handler func(evnt *peerEvent.PeerEvent)) error + func (s *Server) TemporaryDialPeer(peerAddrInfo *peer.AddrInfo) + func (s *Server) UpdatePendingConnCount(delta int64, direction network.Direction) + type Subscription struct + func (s *Subscription) Close() + func (s *Subscription) Get() *peerEvent.PeerEvent + func (s *Subscription) GetCh() chan *peerEvent.PeerEvent + type Topic struct + func (t *Topic) Close() + func (t *Topic) Publish(obj proto.Message) error + func (t *Topic) Subscribe(handler func(obj interface{}, from peer.ID)) error