Package discovery provides service advertisement and peer discovery interfaces for libp2p.



    This section is empty.


    This section is empty.


    This section is empty.


    type Advertiser

    type Advertiser interface {
    	// Advertise advertises a service
    	Advertise(ctx context.Context, ns string, opts ...Option) (time.Duration, error)

      Advertiser is an interface for advertising services

      type Discoverer

      type Discoverer interface {
      	// FindPeers discovers peers providing a service
      	FindPeers(ctx context.Context, ns string, opts ...Option) (<-chan peer.AddrInfo, error)

        Discoverer is an interface for peer discovery

        type Discovery

        type Discovery interface {

          Discovery is an interface that combines service advertisement and peer discovery

          type Option

          type Option func(opts *Options) error

            DiscoveryOpt is a single discovery option.

            func Limit

            func Limit(limit int) Option

              Limit is an option that provides an upper bound on the peer count for discovery

              func TTL

              func TTL(ttl time.Duration) Option

                TTL is an option that provides a hint for the duration of an advertisement

                type Options

                type Options struct {
                	Ttl   time.Duration
                	Limit int
                	// Other (implementation-specific) options
                	Other map[interface{}]interface{}

                  DiscoveryOpts is a set of discovery options.

                  func (*Options) Apply

                  func (opts *Options) Apply(options ...Option) error

                    Apply applies the given options to this DiscoveryOpts