package routing

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

Dependency Relation
	imports 7 packages, and imported by one package

Involved Source Files options.go query.go query_serde.go Package routing provides interfaces for peer routing and content routing in libp2p.
Package-Level Type Names (total 11)
/* sort by: | */
ContentDiscovery is able to retrieve providers for a given CID using the Routing system. Search for peers who are able to provide a given key When count is 0, this method will return an unbounded number of results. ContentRouting (interface) Routing (interface)
ContentProviding is able to announce where to find content on the Routing system. Provide adds the given cid to the content routing system. If 'true' is passed, it also announces it, otherwise it is just kept in the local accounting of which objects are being provided. ContentRouting (interface) Routing (interface)
ContentRouting is a value provider layer of indirection. It is used to find information about who has what content. Content is identified by CID (content identifier), which encodes a hash of the identified content in a future-proof manner. Search for peers who are able to provide a given key When count is 0, this method will return an unbounded number of results. Provide adds the given cid to the content routing system. If 'true' is passed, it also announces it, otherwise it is just kept in the local accounting of which objects are being provided. Routing (interface) ContentRouting : ContentDiscovery ContentRouting : ContentProviding
Option is a single routing option. func (*Options).ToOption() Option func (*Options).Apply(options ...Option) error func Routing.GetValue(context.Context, string, ...Option) ([]byte, error) func Routing.PutValue(context.Context, string, []byte, ...Option) error func Routing.SearchValue(context.Context, string, ...Option) (<-chan []byte, error) func ValueStore.GetValue(context.Context, string, ...Option) ([]byte, error) func ValueStore.PutValue(context.Context, string, []byte, ...Option) error func ValueStore.SearchValue(context.Context, string, ...Option) (<-chan []byte, error) var Expired var Offline
Options is a set of routing options Allow expired values. Offline bool Other (ValueStore implementation specific) options. Apply applies the given options to this Options ToOption converts this Options to a single Option.
PeerRouting is a way to find address information about certain peers. This can be implemented by a simple lookup table, a tracking server, or even a DHT. FindPeer searches for a peer with given ID, returns a peer.AddrInfo with relevant addresses. Routing (interface) github.com/libp2p/go-libp2p/p2p/host/routed.Routing (interface) PeerRouting : github.com/libp2p/go-libp2p/p2p/host/routed.Routing
PubKeyFetcher is an interfaces that should be implemented by value stores that can optimize retrieval of public keys. TODO(steb): Consider removing, see https://github.com/libp2p/go-libp2p-routing/issues/22. GetPublicKey returns the public key for the given peer.
QueryEvent is emitted for every notable event that happens during a DHT query. Extra string ID peer.ID Responses []*peer.AddrInfo Type QueryEventType (*QueryEvent) MarshalJSON() ([]byte, error) (*QueryEvent) UnmarshalJSON(b []byte) error *QueryEvent : github.com/goccy/go-json.Marshaler *QueryEvent : github.com/goccy/go-json.Unmarshaler *QueryEvent : encoding/json.Marshaler *QueryEvent : encoding/json.Unmarshaler func RegisterForQueryEvents(ctx context.Context) (context.Context, <-chan *QueryEvent) func PublishQueryEvent(ctx context.Context, ev *QueryEvent)
QueryEventType indicates the query event's type. const AddingPeer const DialingPeer const FinalPeer const PeerResponse const Provider const QueryError const SendingQuery const Value
Routing is the combination of different routing types supported by libp2p. It can be satisfied by a single item (such as a DHT) or multiple different pieces that are more optimized to each task. Bootstrap allows callers to hint to the routing system to get into a Bootstrapped state and remain there. It is not a synchronous call. FindPeer searches for a peer with given ID, returns a peer.AddrInfo with relevant addresses. Search for peers who are able to provide a given key When count is 0, this method will return an unbounded number of results. GetValue searches for the value corresponding to given Key. Provide adds the given cid to the content routing system. If 'true' is passed, it also announces it, otherwise it is just kept in the local accounting of which objects are being provided. PutValue adds value corresponding to given Key. SearchValue searches for better and better values from this value store corresponding to the given Key. By default, implementations must stop the search after a good value is found. A 'good' value is a value that would be returned from GetValue. Useful when you want a result *now* but still want to hear about better/newer results. Implementations of this methods won't return ErrNotFound. When a value couldn't be found, the channel will get closed without passing any results Routing : ContentDiscovery Routing : ContentProviding Routing : ContentRouting Routing : PeerRouting Routing : ValueStore Routing : github.com/libp2p/go-libp2p/p2p/host/routed.Routing
ValueStore is a basic Put/Get interface. GetValue searches for the value corresponding to given Key. PutValue adds value corresponding to given Key. SearchValue searches for better and better values from this value store corresponding to the given Key. By default, implementations must stop the search after a good value is found. A 'good' value is a value that would be returned from GetValue. Useful when you want a result *now* but still want to hear about better/newer results. Implementations of this methods won't return ErrNotFound. When a value couldn't be found, the channel will get closed without passing any results Routing (interface) func GetPublicKey(r ValueStore, ctx context.Context, p peer.ID) (ci.PubKey, error)
Package-Level Functions (total 5)
GetPublicKey retrieves the public key associated with the given peer ID from the value store. If the ValueStore is also a PubKeyFetcher, this method will call GetPublicKey (which may be better optimized) instead of GetValue.
KeyForPublicKey returns the key used to retrieve public keys from a value store.
PublishQueryEvent publishes a query event to the query event channel associated with the given context, if any.
RegisterForQueryEvents registers a query event channel with the given context. The returned context can be passed to DHT queries to receive query events on the returned channels. The passed context MUST be canceled when the caller is no longer interested in query events.
SubscribesToQueryEvents returns true if the context subscribes to query events. If this function returns false, calling `PublishQueryEvent` on the context will be a no-op.
Package-Level Variables (total 5)
ErrNotFound is returned when the router fails to find the requested record.
ErrNotSupported is returned when the router doesn't support the given record type/operation.
Expired is an option that tells the routing system to return expired records when no newer records are known.
Offline is an option that tells the routing system to operate offline (i.e., rely on cached/local data only).
Number of events to buffer.
Package-Level Constants (total 8)
Adding a peer to the query.
Dialing a peer.
Found a "closest" peer (not currently used).
Got a response from a peer.
Found a provider.
Got an error when querying.
Sending a query to a peer.
Found a value.