registry

package
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2022 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInProgress  = errors.New("discovery already in progress")
	ErrNotAllowed  = errors.New("provider not allowed by policy")
	ErrNoDiscovery = errors.New("discovery not available")
	ErrNotTrusted  = errors.New("provider not trusted to register without on-chain verification")
	ErrNotVerified = errors.New("provider cannot be verified")
	ErrTooSoon     = errors.New("not enough time since previous discovery")
)

Functions

This section is empty.

Types

type ProviderInfo

type ProviderInfo struct {
	// AddrInfo contains a peer.ID and set of Multiaddr addresses.
	AddrInfo peer.AddrInfo
	// DiscoveryAddr is the address that is used for discovery of the provider.
	DiscoveryAddr string `json:",omitempty"`
	// LastAdvertisement identifies the latest advertisement the indexer has ingested.
	LastAdvertisement cid.Cid `json:",omitempty"`
	// LastAdvertisementTime is the time the latest advertisement was received.
	LastAdvertisementTime time.Time `json:",omitempty"`
	// Publisher is the ID of the peer that published the provider info.
	Publisher peer.ID `json:",omitempty"`
	// contains filtered or unexported fields
}

ProviderInfo is an immutable data structure that holds information about a provider. A ProviderInfo instance is never modified, but rather a new one is created to update its contents. This means existing references remain valid.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry stores information about discovered providers

func NewRegistry

func NewRegistry(ctx context.Context, cfg config.Discovery, dstore datastore.Datastore, disco discovery.Discoverer) (*Registry, error)

NewRegistry creates a new provider registry, giving it provider policy configuration, a datastore to persist provider data, and a Discoverer interface. The context is only used for cancellation of this function.

TODO: It is probably necessary to have multiple discoverer interfaces

func (*Registry) AllProviderInfo

func (r *Registry) AllProviderInfo() []*ProviderInfo

AllProviderInfo returns information for all registered providers

func (*Registry) AllowPeer added in v0.2.0

func (r *Registry) AllowPeer(peerID peer.ID) bool

AllowPeer configures the policy to allow messages published by the identified peer, or allow the peer to register as a provider.

func (*Registry) Authorized

func (r *Registry) Authorized(peerID peer.ID) (bool, error)

Check if the peer is trusted by policy, or if it has been previously verified and registered as a provider.

func (*Registry) BlockPeer added in v0.2.0

func (r *Registry) BlockPeer(peerID peer.ID) bool

BlockPeer configures the policy to block messages published by the identified peer, and block the peer from registering as a provider.

func (*Registry) CheckSequence

func (r *Registry) CheckSequence(peerID peer.ID, seq uint64) error

func (*Registry) Close

func (r *Registry) Close() error

Close waits for any pending discoverer to finish and then stops the registry

func (*Registry) Discover

func (r *Registry) Discover(peerID peer.ID, discoveryAddr string, sync bool) error

Discover begins the process of discovering and verifying a provider. The discovery address us used to lookup the provider's information.

TODO: To support multiple discoverer methods (lotus, IPFS, etc.) there need to be information that is part of, or in addition to, the discoveryAddr to indicate where/how discovery is done.

func (*Registry) IsRegistered

func (r *Registry) IsRegistered(providerID peer.ID) bool

IsRegistered checks if the provider is in the registry

func (*Registry) ProviderInfo

func (r *Registry) ProviderInfo(providerID peer.ID) *ProviderInfo

ProviderInfo returns information for a registered provider

func (*Registry) ProviderInfoByAddr

func (r *Registry) ProviderInfoByAddr(discoAddr string) *ProviderInfo

ProviderInfoByAddr finds a registered provider using its discovery address

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, info *ProviderInfo) error

Register is used to directly register a provider, bypassing discovery and adding discovered data directly to the registry.

func (*Registry) RegisterOrUpdate

func (r *Registry) RegisterOrUpdate(ctx context.Context, providerID peer.ID, addrs []string, adID cid.Cid, publisherID peer.ID) error

RegisterOrUpdate attempts to register an unregistered provider, or updates the addresses and latest advertisement of an already registered provider.

func (*Registry) SetPolicy added in v0.2.0

func (r *Registry) SetPolicy(policyCfg config.Policy) error

func (*Registry) SyncChan added in v0.3.6

func (r *Registry) SyncChan() <-chan *ProviderInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL