package peer

Import Path
	github.com/libp2p/go-libp2p/core/peer (on go.dev)

Dependency Relation
	imports 17 packages, and imported by 45 packages

Involved Source Files addrinfo.go addrinfo_serde.go Package peer implements an object used to represent peers in the libp2p network. Package peer contains Protobuf and JSON serialization/deserialization methods for peer IDs. record.go
Package-Level Type Names (total 4)
/* sort by: | */
AddrInfo is a small struct used to pass around a peer with a set of addresses (and later, keys?). Addrs []ma.Multiaddr ID ID (*AddrInfo) Loggable() map[string]interface{} ( AddrInfo) MarshalJSON() (res []byte, err error) ( AddrInfo) String() string (*AddrInfo) UnmarshalJSON(b []byte) (err error) AddrInfo : github.com/goccy/go-json.Marshaler *AddrInfo : github.com/goccy/go-json.Unmarshaler AddrInfo : encoding/json.Marshaler *AddrInfo : encoding/json.Unmarshaler AddrInfo : expvar.Var AddrInfo : fmt.Stringer func AddrInfoFromP2pAddr(m ma.Multiaddr) (*AddrInfo, error) func AddrInfoFromString(s string) (*AddrInfo, error) func AddrInfosFromP2pAddrs(maddrs ...ma.Multiaddr) ([]AddrInfo, error) func github.com/libp2p/go-libp2p/core/discovery.Discoverer.FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan AddrInfo, error) func github.com/libp2p/go-libp2p/core/discovery.Discovery.FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan AddrInfo, error) func github.com/libp2p/go-libp2p/core/host.InfoFromHost(h host.Host) *AddrInfo func github.com/libp2p/go-libp2p/core/peerstore.AddrInfos(ps peerstore.Peerstore, peers []ID) []AddrInfo func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.PeerInfo(ID) AddrInfo func github.com/libp2p/go-libp2p/core/routing.ContentDiscovery.FindProvidersAsync(context.Context, cid.Cid, int) <-chan AddrInfo func github.com/libp2p/go-libp2p/core/routing.ContentRouting.FindProvidersAsync(context.Context, cid.Cid, int) <-chan AddrInfo func github.com/libp2p/go-libp2p/core/routing.PeerRouting.FindPeer(context.Context, ID) (AddrInfo, error) func github.com/libp2p/go-libp2p/core/routing.Routing.FindPeer(context.Context, ID) (AddrInfo, error) func github.com/libp2p/go-libp2p/core/routing.Routing.FindProvidersAsync(context.Context, cid.Cid, int) <-chan AddrInfo func github.com/libp2p/go-libp2p/p2p/discovery/backoff.(*BackoffDiscovery).FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan AddrInfo, error) func github.com/libp2p/go-libp2p/p2p/host/peerstore.PeerInfos(ps pstore.Peerstore, peers IDSlice) []AddrInfo func github.com/libp2p/go-libp2p/p2p/host/routed.Routing.FindPeer(context.Context, ID) (AddrInfo, error) func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/util.PeerToPeerInfoV2(p *pbv2.Peer) (AddrInfo, error) func AddrInfosToIDs(pis []AddrInfo) []ID func AddrInfoToP2pAddrs(pi *AddrInfo) ([]ma.Multiaddr, error) func PeerRecordFromAddrInfo(info AddrInfo) *PeerRecord func github.com/libp2p/go-libp2p/core/host.Host.Connect(ctx context.Context, pi AddrInfo) error func github.com/libp2p/go-libp2p.EnableAutoRelayWithStaticRelays(static []AddrInfo, opts ...autorelay.Option) libp2p.Option func github.com/libp2p/go-libp2p/p2p/discovery/backoff.(*BackoffConnector).Connect(ctx context.Context, peerCh <-chan AddrInfo) func github.com/libp2p/go-libp2p/p2p/host/autorelay.WithStaticRelays(static []AddrInfo) autorelay.Option func github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).Connect(ctx context.Context, pi AddrInfo) error func github.com/libp2p/go-libp2p/p2p/host/blank.(*BlankHost).Connect(ctx context.Context, ai AddrInfo) error func github.com/libp2p/go-libp2p/p2p/host/peerstore.PeerInfoIDs(pis []AddrInfo) IDSlice func github.com/libp2p/go-libp2p/p2p/host/routed.(*RoutedHost).Connect(ctx context.Context, pi AddrInfo) error func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Reserve(ctx context.Context, h host.Host, ai AddrInfo) (*client.Reservation, error) func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/util.PeerInfoToPeerV2(pi AddrInfo) *pbv2.Peer func github.com/libp2p/go-libp2p-pubsub.NewRemoteTracer(ctx context.Context, host host.Host, pi AddrInfo) (*pubsub.RemoteTracer, error) func github.com/libp2p/go-libp2p-pubsub.WithDirectPeers(pis []AddrInfo) pubsub.Option
ID is a libp2p peer identity. Peer IDs are derived by hashing a peer's public key and encoding the hash output as a multihash. See IDFromPublicKey for details. ExtractPublicKey attempts to extract the public key from an ID. This method returns ErrNoPublicKey if the peer ID looks valid, but it can't extract the public key. Loggable returns a pretty peer ID string in loggable JSON format. ( ID) Marshal() ([]byte, error) MarshalBinary returns the byte representation of the peer ID. ( ID) MarshalJSON() ([]byte, error) MarshalText returns the text encoding of the ID. ( ID) MarshalTo(data []byte) (n int, err error) MatchesPrivateKey tests whether this ID was derived from the secret key sk. MatchesPublicKey tests whether this ID was derived from the public key pk. ShortString prints out the peer ID. TODO(brian): ensure correctness at ID generation and enforce this by only exposing functions that generate IDs safely. Then any peer.ID type found in the codebase is known to be correct. ( ID) Size() int ( ID) String() string (*ID) Unmarshal(data []byte) (err error) UnmarshalBinary sets the ID from its binary representation. (*ID) UnmarshalJSON(data []byte) (err error) UnmarshalText restores the ID from its text encoding. Validate checks if ID is empty or not. ID : github.com/goccy/go-json.Marshaler *ID : github.com/goccy/go-json.Unmarshaler ID : github.com/gogo/protobuf/proto.Marshaler ID : github.com/gogo/protobuf/proto.Sizer *ID : github.com/gogo/protobuf/proto.Unmarshaler ID : github.com/golang/protobuf/proto.Marshaler *ID : github.com/golang/protobuf/proto.Unmarshaler *ID : github.com/pion/rtcp.PacketStatusChunk ID : encoding.BinaryMarshaler *ID : encoding.BinaryUnmarshaler ID : encoding.TextMarshaler *ID : encoding.TextUnmarshaler ID : encoding/json.Marshaler *ID : encoding/json.Unmarshaler ID : expvar.Var ID : fmt.Stringer func AddrInfosToIDs(pis []AddrInfo) []ID func Decode(s string) (ID, error) func FromCid(c cid.Cid) (ID, error) func IDFromBytes(b []byte) (ID, error) func IDFromP2PAddr(m ma.Multiaddr) (ID, error) func IDFromPrivateKey(sk ic.PrivKey) (ID, error) func IDFromPublicKey(pk ic.PubKey) (ID, error) func SplitAddr(m ma.Multiaddr) (transport ma.Multiaddr, id ID) func github.com/libp2p/go-libp2p/core/host.Host.ID() ID func github.com/libp2p/go-libp2p/core/metrics.(*BandwidthCounter).GetBandwidthByPeer() map[ID]metrics.Stats func github.com/libp2p/go-libp2p/core/metrics.Reporter.GetBandwidthByPeer() map[ID]metrics.Stats func github.com/libp2p/go-libp2p/core/network.Conn.LocalPeer() ID func github.com/libp2p/go-libp2p/core/network.Conn.RemotePeer() ID func github.com/libp2p/go-libp2p/core/network.ConnSecurity.LocalPeer() ID func github.com/libp2p/go-libp2p/core/network.ConnSecurity.RemotePeer() ID func github.com/libp2p/go-libp2p/core/network.Dialer.LocalPeer() ID func github.com/libp2p/go-libp2p/core/network.Dialer.Peers() []ID func github.com/libp2p/go-libp2p/core/network.Network.LocalPeer() ID func github.com/libp2p/go-libp2p/core/network.Network.Peers() []ID func github.com/libp2p/go-libp2p/core/network.(*NullScope).Peer() ID func github.com/libp2p/go-libp2p/core/network.PeerScope.Peer() ID func github.com/libp2p/go-libp2p/core/sec.SecureConn.LocalPeer() ID func github.com/libp2p/go-libp2p/core/sec.SecureConn.RemotePeer() ID func github.com/libp2p/go-libp2p/core/sec/insecure.(*Conn).LocalPeer() ID func github.com/libp2p/go-libp2p/core/sec/insecure.(*Conn).RemotePeer() ID func github.com/libp2p/go-libp2p/core/sec/insecure.(*Transport).LocalPeer() ID func github.com/libp2p/go-libp2p/core/transport.CapableConn.LocalPeer() ID func github.com/libp2p/go-libp2p/core/transport.CapableConn.RemotePeer() ID func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.LocalPeer() ID func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.Peers() []ID func github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).ID() ID func github.com/libp2p/go-libp2p/p2p/host/blank.(*BlankHost).ID() ID func github.com/libp2p/go-libp2p/p2p/host/resource-manager.ResourceManagerState.ListPeers() []ID func github.com/libp2p/go-libp2p/p2p/host/routed.(*RoutedHost).ID() ID func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Conn).LocalPeer() ID func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Conn).RemotePeer() ID func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).LocalPeer() ID func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).Peers() []ID func github.com/libp2p/go-libp2p-pubsub.(*Message).GetFrom() ID func github.com/libp2p/go-libp2p-pubsub.(*PubSub).ListPeers(topic string) []ID func github.com/libp2p/go-libp2p-pubsub.(*Topic).ListPeers() []ID func ToCid(id ID) cid.Cid func github.com/libp2p/go-libp2p/core/canonicallog.LogMisbehavingPeer(p ID, peerAddr multiaddr.Multiaddr, component string, err error, msg string) func github.com/libp2p/go-libp2p/core/canonicallog.LogMisbehavingPeerNetAddr(p ID, peerAddr net.Addr, component string, originalErr error, msg string) func github.com/libp2p/go-libp2p/core/canonicallog.LogPeerStatus(sampleRate int, p ID, peerAddr multiaddr.Multiaddr, keyVals ...string) func github.com/libp2p/go-libp2p/core/connmgr.ConnectionGater.InterceptAddrDial(ID, ma.Multiaddr) (allow bool) func github.com/libp2p/go-libp2p/core/connmgr.ConnectionGater.InterceptPeerDial(p ID) (allow bool) func github.com/libp2p/go-libp2p/core/connmgr.ConnectionGater.InterceptSecured(network.Direction, ID, network.ConnMultiaddrs) (allow bool) func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.GetTagInfo(p ID) *connmgr.TagInfo func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.IsProtected(id ID, tag string) (protected bool) func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.Protect(id ID, tag string) func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.TagPeer(ID, string, int) func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.Unprotect(id ID, tag string) (protected bool) func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.UntagPeer(p ID, tag string) func github.com/libp2p/go-libp2p/core/connmgr.ConnManager.UpsertTag(p ID, tag string, upsert func(int) int) func github.com/libp2p/go-libp2p/core/connmgr.DecayingTag.Bump(peer ID, delta int) error func github.com/libp2p/go-libp2p/core/connmgr.DecayingTag.Remove(peer ID) error func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.GetTagInfo(ID) *connmgr.TagInfo func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.IsProtected(ID, string) bool func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.Protect(ID, string) func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.TagPeer(ID, string, int) func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.Unprotect(ID, string) bool func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.UntagPeer(ID, string) func github.com/libp2p/go-libp2p/core/connmgr.NullConnMgr.UpsertTag(ID, string, func(int) int) func github.com/libp2p/go-libp2p/core/host.Host.NewStream(ctx context.Context, p ID, pids ...protocol.ID) (network.Stream, error) func github.com/libp2p/go-libp2p/core/metrics.(*BandwidthCounter).GetBandwidthForPeer(p ID) (out metrics.Stats) func github.com/libp2p/go-libp2p/core/metrics.(*BandwidthCounter).LogRecvMessageStream(size int64, proto protocol.ID, p ID) func github.com/libp2p/go-libp2p/core/metrics.(*BandwidthCounter).LogSentMessageStream(size int64, proto protocol.ID, p ID) func github.com/libp2p/go-libp2p/core/metrics.Reporter.GetBandwidthForPeer(ID) metrics.Stats func github.com/libp2p/go-libp2p/core/metrics.Reporter.LogRecvMessageStream(int64, protocol.ID, ID) func github.com/libp2p/go-libp2p/core/metrics.Reporter.LogSentMessageStream(int64, protocol.ID, ID) func github.com/libp2p/go-libp2p/core/network.ConnManagementScope.SetPeer(ID) error func github.com/libp2p/go-libp2p/core/network.Dialer.CanDial(p ID, addr ma.Multiaddr) bool func github.com/libp2p/go-libp2p/core/network.Dialer.ClosePeer(ID) error func github.com/libp2p/go-libp2p/core/network.Dialer.Connectedness(ID) network.Connectedness func github.com/libp2p/go-libp2p/core/network.Dialer.ConnsToPeer(p ID) []network.Conn func github.com/libp2p/go-libp2p/core/network.Dialer.DialPeer(context.Context, ID) (network.Conn, error) func github.com/libp2p/go-libp2p/core/network.MultiaddrDNSResolver.ResolveDNSAddr(ctx context.Context, expectedPeerID ID, maddr ma.Multiaddr, recursionLimit, outputLimit int) ([]ma.Multiaddr, error) func github.com/libp2p/go-libp2p/core/network.Network.CanDial(p ID, addr ma.Multiaddr) bool func github.com/libp2p/go-libp2p/core/network.Network.ClosePeer(ID) error func github.com/libp2p/go-libp2p/core/network.Network.Connectedness(ID) network.Connectedness func github.com/libp2p/go-libp2p/core/network.Network.ConnsToPeer(p ID) []network.Conn func github.com/libp2p/go-libp2p/core/network.Network.DialPeer(context.Context, ID) (network.Conn, error) func github.com/libp2p/go-libp2p/core/network.Network.NewStream(context.Context, ID) (network.Stream, error) func github.com/libp2p/go-libp2p/core/network.(*NullResourceManager).OpenStream(_ ID, _ network.Direction) (network.StreamManagementScope, error) func github.com/libp2p/go-libp2p/core/network.(*NullResourceManager).ViewPeer(_ ID, f func(network.PeerScope) error) error func github.com/libp2p/go-libp2p/core/network.(*NullScope).SetPeer(ID) error func github.com/libp2p/go-libp2p/core/network.ResourceManager.OpenStream(p ID, dir network.Direction) (network.StreamManagementScope, error) func github.com/libp2p/go-libp2p/core/network.ResourceManager.ViewPeer(ID, func(network.PeerScope) error) error func github.com/libp2p/go-libp2p/core/network.ResourceScopeViewer.ViewPeer(ID, func(network.PeerScope) error) error func github.com/libp2p/go-libp2p/core/peerstore.AddrInfos(ps peerstore.Peerstore, peers []ID) []AddrInfo func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.AddAddr(p ID, addr ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.AddAddrs(p ID, addrs []ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.Addrs(p ID) []ma.Multiaddr func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.AddrStream(context.Context, ID) <-chan ma.Multiaddr func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.ClearAddrs(p ID) func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.SetAddr(p ID, addr ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.SetAddrs(p ID, addrs []ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.UpdateAddrs(p ID, oldTTL time.Duration, newTTL time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.CertifiedAddrBook.GetPeerRecord(p ID) *record.Envelope func github.com/libp2p/go-libp2p/core/peerstore.KeyBook.AddPrivKey(ID, ic.PrivKey) error func github.com/libp2p/go-libp2p/core/peerstore.KeyBook.AddPubKey(ID, ic.PubKey) error func github.com/libp2p/go-libp2p/core/peerstore.KeyBook.PrivKey(ID) ic.PrivKey func github.com/libp2p/go-libp2p/core/peerstore.KeyBook.PubKey(ID) ic.PubKey func github.com/libp2p/go-libp2p/core/peerstore.KeyBook.RemovePeer(ID) func github.com/libp2p/go-libp2p/core/peerstore.Metrics.LatencyEWMA(ID) time.Duration func github.com/libp2p/go-libp2p/core/peerstore.Metrics.RecordLatency(ID, time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.Metrics.RemovePeer(ID) func github.com/libp2p/go-libp2p/core/peerstore.PeerMetadata.Get(p ID, key string) (interface{}, error) func github.com/libp2p/go-libp2p/core/peerstore.PeerMetadata.Put(p ID, key string, val interface{}) error func github.com/libp2p/go-libp2p/core/peerstore.PeerMetadata.RemovePeer(ID) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.AddAddr(p ID, addr ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.AddAddrs(p ID, addrs []ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.AddPrivKey(ID, ic.PrivKey) error func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.AddProtocols(ID, ...protocol.ID) error func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.AddPubKey(ID, ic.PubKey) error func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.Addrs(p ID) []ma.Multiaddr func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.AddrStream(context.Context, ID) <-chan ma.Multiaddr func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.ClearAddrs(p ID) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.FirstSupportedProtocol(ID, ...protocol.ID) (protocol.ID, error) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.Get(p ID, key string) (interface{}, error) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.GetProtocols(ID) ([]protocol.ID, error) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.LatencyEWMA(ID) time.Duration func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.PeerInfo(ID) AddrInfo func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.PrivKey(ID) ic.PrivKey func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.PubKey(ID) ic.PubKey func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.Put(p ID, key string, val interface{}) error func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.RecordLatency(ID, time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.RemovePeer(ID) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.RemoveProtocols(ID, ...protocol.ID) error func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.SetAddr(p ID, addr ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.SetAddrs(p ID, addrs []ma.Multiaddr, ttl time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.SetProtocols(ID, ...protocol.ID) error func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.SupportsProtocols(ID, ...protocol.ID) ([]protocol.ID, error) func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.UpdateAddrs(p ID, oldTTL time.Duration, newTTL time.Duration) func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.AddProtocols(ID, ...protocol.ID) error func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.FirstSupportedProtocol(ID, ...protocol.ID) (protocol.ID, error) func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.GetProtocols(ID) ([]protocol.ID, error) func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.RemovePeer(ID) func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.RemoveProtocols(ID, ...protocol.ID) error func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.SetProtocols(ID, ...protocol.ID) error func github.com/libp2p/go-libp2p/core/peerstore.ProtoBook.SupportsProtocols(ID, ...protocol.ID) ([]protocol.ID, error) func github.com/libp2p/go-libp2p/core/routing.GetPublicKey(r routing.ValueStore, ctx context.Context, p ID) (ci.PubKey, error) func github.com/libp2p/go-libp2p/core/routing.KeyForPublicKey(id ID) string func github.com/libp2p/go-libp2p/core/routing.PeerRouting.FindPeer(context.Context, ID) (AddrInfo, error) func github.com/libp2p/go-libp2p/core/routing.PubKeyFetcher.GetPublicKey(context.Context, ID) (ci.PubKey, error) func github.com/libp2p/go-libp2p/core/routing.Routing.FindPeer(context.Context, ID) (AddrInfo, error) func github.com/libp2p/go-libp2p/core/sec.SecureTransport.SecureInbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/core/sec.SecureTransport.SecureOutbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/core/sec/insecure.NewWithIdentity(protocolID protocol.ID, id ID, key ci.PrivKey) *insecure.Transport func github.com/libp2p/go-libp2p/core/sec/insecure.(*Transport).SecureInbound(_ context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/core/sec/insecure.(*Transport).SecureOutbound(_ context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/core/transport.DialUpdater.DialWithUpdates(context.Context, ma.Multiaddr, ID, chan<- transport.DialUpdate) (transport.CapableConn, error) func github.com/libp2p/go-libp2p/core/transport.Transport.Dial(ctx context.Context, raddr ma.Multiaddr, p ID) (transport.CapableConn, error) func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.CanDial(p ID, addr ma.Multiaddr) bool func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.ClosePeer(ID) error func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.Connectedness(ID) network.Connectedness func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.ConnsToPeer(p ID) []network.Conn func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.DialPeer(context.Context, ID) (network.Conn, error) func github.com/libp2p/go-libp2p/core/transport.TransportNetwork.NewStream(context.Context, ID) (network.Stream, error) func github.com/libp2p/go-libp2p/core/transport.Upgrader.Upgrade(ctx context.Context, t transport.Transport, maconn manet.Conn, dir network.Direction, p ID, scope network.ConnManagementScope) (transport.CapableConn, error) func github.com/libp2p/go-libp2p/p2p/host/autonat.Client.DialBack(ctx context.Context, p ID) error func github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).NewStream(ctx context.Context, p ID, pids ...protocol.ID) (str network.Stream, strErr error) func github.com/libp2p/go-libp2p/p2p/host/blank.(*BlankHost).NewStream(ctx context.Context, p ID, protos ...protocol.ID) (network.Stream, error) func github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem.(*AddrSubManager).AddrStream(ctx context.Context, p ID, initial []ma.Multiaddr) <-chan ma.Multiaddr func github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem.(*AddrSubManager).BroadcastAddr(p ID, addr ma.Multiaddr) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.(*Allowlist).AllowedPeerAndMultiaddr(peerID ID, ma multiaddr.Multiaddr) bool func github.com/libp2p/go-libp2p/p2p/host/resource-manager.Limiter.GetPeerLimits(p ID) rcmgr.Limit func github.com/libp2p/go-libp2p/p2p/host/resource-manager.Limiter.GetStreamLimits(p ID) rcmgr.Limit func github.com/libp2p/go-libp2p/p2p/host/resource-manager.MetricsReporter.AllowPeer(p ID) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.MetricsReporter.AllowStream(p ID, dir network.Direction) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.MetricsReporter.BlockPeer(p ID) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.MetricsReporter.BlockProtocolPeer(proto protocol.ID, p ID) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.MetricsReporter.BlockServicePeer(svc string, p ID) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.MetricsReporter.BlockStream(p ID, dir network.Direction) func github.com/libp2p/go-libp2p/p2p/host/resource-manager.(*ScalingLimitConfig).AddPeerLimit(p ID, base rcmgr.BaseLimit, inc rcmgr.BaseLimitIncrease) func github.com/libp2p/go-libp2p/p2p/host/routed.(*RoutedHost).NewStream(ctx context.Context, p ID, pids ...protocol.ID) (network.Stream, error) func github.com/libp2p/go-libp2p/p2p/host/routed.Routing.FindPeer(context.Context, ID) (AddrInfo, error) func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).GetTagInfo(p ID) *connmgr.TagInfo func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).IsProtected(id ID, tag string) (protected bool) func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).Protect(id ID, tag string) func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).TagPeer(p ID, tag string, val int) func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).Unprotect(id ID, tag string) (protected bool) func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).UntagPeer(p ID, tag string) func github.com/libp2p/go-libp2p/p2p/net/connmgr.(*BasicConnMgr).UpsertTag(p ID, tag string, upsert func(int) int) func github.com/libp2p/go-libp2p/p2p/net/swarm.NewSwarm(local ID, peers peerstore.Peerstore, eventBus event.Bus, opts ...swarm.Option) (*swarm.Swarm, error) func github.com/libp2p/go-libp2p/p2p/net/swarm.(*DialBackoff).AddBackoff(p ID, addr ma.Multiaddr) func github.com/libp2p/go-libp2p/p2p/net/swarm.(*DialBackoff).Backoff(p ID, addr ma.Multiaddr) (backoff bool) func github.com/libp2p/go-libp2p/p2p/net/swarm.(*DialBackoff).Clear(p ID) func github.com/libp2p/go-libp2p/p2p/net/swarm.ResolverFromMaDNS.ResolveDNSAddr(ctx context.Context, expectedPeerID ID, maddr ma.Multiaddr, recursionLimit int, outputLimit int) ([]ma.Multiaddr, error) func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).CanDial(p ID, addr ma.Multiaddr) bool func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).ClosePeer(p ID) error func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).Connectedness(p ID) network.Connectedness func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).ConnsToPeer(p ID) []network.Conn func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).DialPeer(ctx context.Context, p ID) (network.Conn, error) func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).NewStream(ctx context.Context, p ID) (network.Stream, error) func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.(*Client).Dial(ctx context.Context, a ma.Multiaddr, p ID) (transport.CapableConn, error) func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay.ACLFilter.AllowConnect(src ID, srcAddr ma.Multiaddr, dest ID) bool func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay.ACLFilter.AllowConnect(src ID, srcAddr ma.Multiaddr, dest ID) bool func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/relay.ACLFilter.AllowReserve(p ID, a ma.Multiaddr) bool func github.com/libp2p/go-libp2p/p2p/protocol/holepunch.AddrFilter.FilterLocal(remoteID ID, maddrs []ma.Multiaddr) []ma.Multiaddr func github.com/libp2p/go-libp2p/p2p/protocol/holepunch.AddrFilter.FilterRemote(remoteID ID, maddrs []ma.Multiaddr) []ma.Multiaddr func github.com/libp2p/go-libp2p/p2p/protocol/holepunch.(*Service).DirectConnect(p ID) error func github.com/libp2p/go-libp2p/p2p/protocol/ping.Ping(ctx context.Context, h host.Host, p ID) <-chan ping.Result func github.com/libp2p/go-libp2p/p2p/protocol/ping.(*PingService).Ping(ctx context.Context, p ID) <-chan ping.Result func github.com/libp2p/go-libp2p/p2p/security/noise.EarlyDataHandler.Send(context.Context, net.Conn, ID) *pb.NoiseExtensions func github.com/libp2p/go-libp2p/p2p/security/noise.(*SessionTransport).SecureInbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/p2p/security/noise.(*SessionTransport).SecureOutbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/p2p/security/noise.(*Transport).SecureInbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/p2p/security/noise.(*Transport).SecureOutbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/p2p/security/tls.(*Identity).ConfigForPeer(remote ID) (*tls.Config, <-chan ic.PubKey) func github.com/libp2p/go-libp2p/p2p/security/tls.(*Transport).SecureInbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/p2p/security/tls.(*Transport).SecureOutbound(ctx context.Context, insecure net.Conn, p ID) (sec.SecureConn, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.(*TcpTransport).Dial(ctx context.Context, raddr ma.Multiaddr, p ID) (transport.CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.(*TcpTransport).DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p ID, updateChan chan<- transport.DialUpdate) (transport.CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/webrtc.(*WebRTCTransport).Dial(ctx context.Context, remoteMultiaddr ma.Multiaddr, p ID) (tpt.CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).Dial(ctx context.Context, raddr ma.Multiaddr, p ID) (transport.CapableConn, error) func github.com/libp2p/go-libp2p-pubsub.DefaultPeerFilter(pid ID, topic string) bool func github.com/libp2p/go-libp2p-pubsub.WithMessageAuthor(author ID) pubsub.Option func github.com/libp2p/go-libp2p-pubsub.WithSecretKeyAndPeerId(key crypto.PrivKey, pid ID) pubsub.PubOpt func github.com/libp2p/go-libp2p-pubsub.Blacklist.Add(ID) bool func github.com/libp2p/go-libp2p-pubsub.Blacklist.Contains(ID) bool func github.com/libp2p/go-libp2p-pubsub.(*FloodSubRouter).AcceptFrom(ID) pubsub.AcceptStatus func github.com/libp2p/go-libp2p-pubsub.(*FloodSubRouter).AddPeer(p ID, proto protocol.ID) func github.com/libp2p/go-libp2p-pubsub.(*FloodSubRouter).RemovePeer(p ID) func github.com/libp2p/go-libp2p-pubsub.(*GossipSubRouter).AcceptFrom(p ID) pubsub.AcceptStatus func github.com/libp2p/go-libp2p-pubsub.(*GossipSubRouter).AddPeer(p ID, proto protocol.ID) func github.com/libp2p/go-libp2p-pubsub.(*GossipSubRouter).RemovePeer(p ID) func github.com/libp2p/go-libp2p-pubsub.(*GossipSubRouter).SendControl(p ID, ctl *pb.ControlMessage, msgs ...*pb.Message) func github.com/libp2p/go-libp2p-pubsub.MapBlacklist.Add(p ID) bool func github.com/libp2p/go-libp2p-pubsub.MapBlacklist.Contains(p ID) bool func github.com/libp2p/go-libp2p-pubsub.(*MessageCache).GetForPeer(mid string, p ID) (*pubsub.Message, int, bool) func github.com/libp2p/go-libp2p-pubsub.PeerMetadataStore.Get(context.Context, ID) ([]byte, error) func github.com/libp2p/go-libp2p-pubsub.PeerMetadataStore.Put(context.Context, ID, []byte) error func github.com/libp2p/go-libp2p-pubsub.(*PubSub).BlacklistPeer(pid ID) func github.com/libp2p/go-libp2p-pubsub.PubSubRouter.AcceptFrom(ID) pubsub.AcceptStatus func github.com/libp2p/go-libp2p-pubsub.PubSubRouter.AddPeer(ID, protocol.ID) func github.com/libp2p/go-libp2p-pubsub.PubSubRouter.RemovePeer(ID) func github.com/libp2p/go-libp2p-pubsub.(*RandomSubRouter).AcceptFrom(ID) pubsub.AcceptStatus func github.com/libp2p/go-libp2p-pubsub.(*RandomSubRouter).AddPeer(p ID, proto protocol.ID) func github.com/libp2p/go-libp2p-pubsub.(*RandomSubRouter).RemovePeer(p ID) func github.com/libp2p/go-libp2p-pubsub.RawTracer.AddPeer(p ID, proto protocol.ID) func github.com/libp2p/go-libp2p-pubsub.RawTracer.DropRPC(rpc *pubsub.RPC, p ID) func github.com/libp2p/go-libp2p-pubsub.RawTracer.Graft(p ID, topic string) func github.com/libp2p/go-libp2p-pubsub.RawTracer.Prune(p ID, topic string) func github.com/libp2p/go-libp2p-pubsub.RawTracer.RemovePeer(p ID) func github.com/libp2p/go-libp2p-pubsub.RawTracer.SendRPC(rpc *pubsub.RPC, p ID) func github.com/libp2p/go-libp2p-pubsub.RawTracer.ThrottlePeer(p ID) func github.com/libp2p/go-libp2p-pubsub.SubscriptionFilter.FilterIncomingSubscriptions(ID, []*pb.RPC_SubOpts) ([]*pb.RPC_SubOpts, error) func github.com/libp2p/go-libp2p-pubsub.(*TimeCachedBlacklist).Add(p ID) bool func github.com/libp2p/go-libp2p-pubsub.(*TimeCachedBlacklist).Contains(p ID) bool func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.(*UdsTransport).Dial(ctx context.Context, raddr ma.Multiaddr, p ID) (transport.CapableConn, error) func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.(*UdsTransport).DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p ID, updateChan chan<- transport.DialUpdate) (transport.CapableConn, error)
IDSlice for sorting peers. ( IDSlice) Len() int ( IDSlice) Less(i, j int) bool ( IDSlice) String() string ( IDSlice) Swap(i, j int) IDSlice : expvar.Var IDSlice : fmt.Stringer IDSlice : sort.Interface func github.com/libp2p/go-libp2p/core/peerstore.AddrBook.PeersWithAddrs() IDSlice func github.com/libp2p/go-libp2p/core/peerstore.KeyBook.PeersWithKeys() IDSlice func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.Peers() IDSlice func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.PeersWithAddrs() IDSlice func github.com/libp2p/go-libp2p/core/peerstore.Peerstore.PeersWithKeys() IDSlice func github.com/libp2p/go-libp2p/p2p/host/peerstore.PeerInfoIDs(pis []AddrInfo) IDSlice func github.com/libp2p/go-libp2p/p2p/host/peerstore.PeerInfos(ps pstore.Peerstore, peers IDSlice) []AddrInfo
PeerRecord contains information that is broadly useful to share with other peers, either through a direct exchange (as in the libp2p identify protocol), or through a Peer Routing provider, such as a DHT. Currently, a PeerRecord contains the public listen addresses for a peer, but this is expected to expand to include other information in the future. PeerRecords are ordered in time by their Seq field. Newer PeerRecords must have greater Seq values than older records. The NewPeerRecord function will create a PeerRecord with a timestamp-based Seq value. The other PeerRecord fields should be set by the caller: rec := peer.NewPeerRecord() rec.PeerID = aPeerID rec.Addrs = someAddrs Alternatively, you can construct a PeerRecord struct directly and use the TimestampSeq helper to set the Seq field: rec := peer.PeerRecord{PeerID: aPeerID, Addrs: someAddrs, Seq: peer.TimestampSeq()} Failing to set the Seq field will not result in an error, however, a PeerRecord with a Seq value of zero may be ignored or rejected by other peers. PeerRecords are intended to be shared with other peers inside a signed routing.Envelope, and PeerRecord implements the routing.Record interface to facilitate this. To share a PeerRecord, first call Sign to wrap the record in an Envelope and sign it with the local peer's private key: rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs} envelope, err := rec.Sign(myPrivateKey) The resulting record.Envelope can be marshalled to a []byte and shared publicly. As a convenience, the MarshalSigned method will produce the Envelope and marshal it to a []byte in one go: rec := &PeerRecord{PeerID: myPeerId, Addrs: myAddrs} recordBytes, err := rec.MarshalSigned(myPrivateKey) To validate and unmarshal a signed PeerRecord from a remote peer, "consume" the containing envelope, which will return both the routing.Envelope and the inner Record. The Record must be cast to a PeerRecord pointer before use: envelope, untypedRecord, err := ConsumeEnvelope(envelopeBytes, PeerRecordEnvelopeDomain) if err != nil { handleError(err) return } peerRec := untypedRecord.(*PeerRecord) Addrs contains the public addresses of the peer this record pertains to. PeerID is the ID of the peer this record pertains to. Seq is a monotonically-increasing sequence counter that's used to order PeerRecords in time. The interval between Seq values is unspecified, but newer PeerRecords MUST have a greater Seq value than older records for the same peer. Codec is a binary identifier for the PeerRecord type. It is constant for all PeerRecord instances. Domain is used when signing and validating PeerRecords contained in Envelopes. It is constant for all PeerRecord instances. Equal returns true if the other PeerRecord is identical to this one. MarshalRecord serializes a PeerRecord to a byte slice. This method is called automatically when constructing a routing.Envelope using Seal or PeerRecord.Sign. ToProtobuf returns the equivalent Protocol Buffer struct object of a PeerRecord. UnmarshalRecord parses a PeerRecord from a byte slice. This method is called automatically when consuming a record.Envelope whose PayloadType indicates that it contains a PeerRecord. It is generally not necessary or recommended to call this method directly. *PeerRecord : github.com/libp2p/go-libp2p/core/record.Record func NewPeerRecord() *PeerRecord func PeerRecordFromAddrInfo(info AddrInfo) *PeerRecord func PeerRecordFromProtobuf(msg *pb.PeerRecord) (*PeerRecord, error) func (*PeerRecord).Equal(other *PeerRecord) bool
Package-Level Functions (total 17)
AddrInfoFromP2pAddr converts a Multiaddr to an AddrInfo.
AddrInfoFromString builds an AddrInfo from the string representation of a Multiaddr
AddrInfosFromP2pAddrs converts a set of Multiaddrs to a set of AddrInfos.
AddrInfosToIDs extracts the peer IDs from the passed AddrInfos and returns them in-order.
AddrInfoToP2pAddrs converts an AddrInfo to a list of Multiaddrs.
Decode accepts an encoded peer ID and returns the decoded ID if the input is valid. The encoded peer ID can either be a CID of a key or a raw multihash (identity or sha256-256).
FromCid converts a CID to a peer ID, if possible.
IDFromBytes casts a byte slice to the ID type, and validates the value to make sure it is a multihash.
IDFromP2PAddr extracts the peer ID from a p2p Multiaddr
IDFromPrivateKey returns the Peer ID corresponding to the secret key sk.
IDFromPublicKey returns the Peer ID corresponding to the public key pk.
NewPeerRecord returns a PeerRecord with a timestamp-based sequence number. The returned record is otherwise empty and should be populated by the caller.
PeerRecordFromAddrInfo creates a PeerRecord from an AddrInfo struct. The returned record will have a timestamp-based sequence number.
PeerRecordFromProtobuf creates a PeerRecord from a protobuf PeerRecord struct.
SplitAddr splits a p2p Multiaddr into a transport multiaddr and a peer ID. * Returns a nil transport if the address only contains a /p2p part. * Returns an empty peer ID if the address doesn't contain a /p2p part.
TimestampSeq is a helper to generate a timestamp-based sequence number for a PeerRecord.
ToCid encodes a peer ID as a CID of the public key. If the peer ID is invalid (e.g., empty), this will return the empty CID.
Package-Level Variables (total 5)
AdvancedEnableInlining enables automatically inlining keys shorter than 42 bytes into the peer ID (using the "identity" multihash function). WARNING: This flag will likely be set to false in the future and eventually be removed in favor of using a hash function specified by the key itself. See: https://github.com/libp2p/specs/issues/138 DO NOT change this flag unless you know what you're doing. This currently defaults to true for backwards compatibility but will likely be set to false by default when an upgrade path is determined.
ErrEmptyPeerID is an error for empty peer ID.
ErrNoPublicKey is an error for peer IDs that don't embed public keys
PeerRecordEnvelopePayloadType is the type hint used to identify peer records in an Envelope. Defined in https://github.com/multiformats/multicodec/blob/master/table.csv with name "libp2p-peer-record".
Package-Level Constants (only one)
PeerRecordEnvelopeDomain is the domain string used for peer records contained in an Envelope.