Versions in this module Expand all Collapse all v0 v0.0.1 May 23, 2023 Changes in this version + const DefaultDialRatio + const DefaultLeaveTimeout + const DefaultLibp2pPort + 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 ErrNoBootnodes = errors.New("no bootnodes specified") + func DisconnectAndWait(source *Server, target peer.ID, leaveTimeout time.Duration) error + func GenerateAndEncodeLibp2pKey() (crypto.PrivKey, []byte, error) + func GenerateTestLibp2pKey(t *testing.T) (crypto.PrivKey, string) + func JoinAndWait(source, destination *Server, connectTimeout time.Duration, ...) error + func JoinAndWaitMultiple(timeout time.Duration, servers ...*Server) error + func MeshJoin(servers ...*Server) []error + func ParseLibp2pKey(key []byte) (crypto.PrivKey, error) + func ReadLibp2pKey(manager secrets.SecretsManager) (crypto.PrivKey, error) + func WaitUntilPeerConnectsTo(ctx context.Context, srv *Server, ids ...peer.ID) (bool, error) + func WaitUntilPeerDisconnectsFrom(ctx context.Context, srv *Server, ids ...peer.ID) (bool, error) + func WaitUntilRoutingTableToBeFilled(ctx context.Context, srv *Server, size int) (bool, error) + type Config struct + Addr *net.TCPAddr + Chain *chain.Chain + DNS multiaddr.Multiaddr + DataDir string + MaxInboundPeers int64 + MaxOutboundPeers int64 + MaxPeers int64 + NatAddr net.IP + 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 CreateServerParams struct + ConfigCallback func(c *Config) + Logger hclog.Logger + ServerCallback func(server *Server) + type PeerConnInfo struct + Info peer.AddrInfo + type Protocol interface + Client func(network.Stream) (*rawGrpc.ClientConn, error) + Handler func() func(network.Stream) + type Server struct + func CreateServer(params *CreateServerParams) (*Server, error) + func NewServer(logger hclog.Logger, config *Config) (*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) GetPeerDistance(peerID peer.ID) *big.Int + func (s *Server) GetPeerInfo(peerID peer.ID) *peer.AddrInfo + func (s *Server) GetProtocols(peerID peer.ID) ([]string, 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() 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