Documentation ¶
Index ¶
- Variables
- type ProviderInfo
- type Registry
- func (r *Registry) AllProviderInfo() []*ProviderInfo
- func (r *Registry) AllowPeer(peerID peer.ID) bool
- func (r *Registry) Allowed(peerID peer.ID) bool
- func (r *Registry) BlockPeer(peerID peer.ID) bool
- func (r *Registry) CheckSequence(peerID peer.ID, seq uint64) error
- func (r *Registry) Close() error
- func (r *Registry) Discover(peerID peer.ID, discoveryAddr string, sync bool) error
- func (r *Registry) FilterIPsEnabled() bool
- func (r *Registry) ImportProviders(ctx context.Context, fromURL *url.URL) (int, error)
- func (r *Registry) IsRegistered(providerID peer.ID) bool
- func (r *Registry) ProviderInfo(providerID peer.ID) (*ProviderInfo, bool)
- func (r *Registry) PublishAllowed(publisherID, providerID peer.ID) bool
- func (r *Registry) Register(ctx context.Context, info *ProviderInfo) error
- func (r *Registry) RegisterOrUpdate(ctx context.Context, provider peer.AddrInfo, adID cid.Cid, ...) error
- func (r *Registry) RemoveProvider(ctx context.Context, providerID peer.ID) error
- func (r *Registry) Saw(provider peer.ID)
- func (r *Registry) SetPolicy(policyCfg config.Policy) error
- func (r *Registry) SyncChan() <-chan *ProviderInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrInProgress = errors.New("discovery already in progress") ErrCannotPublish = errors.New("publisher not allowed to publish to other provider") ErrNotAllowed = errors.New("provider not allowed by policy") ErrNoDiscovery = errors.New("discovery not available") ErrNotVerified = errors.New("provider cannot be verified") ErrPublisherNotAllowed = errors.New("publisher not allowed by policy") 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 contains the ID of the provider info publisher. Publisher peer.ID `json:",omitempty"` // PublisherAddr contains the last seen publisher multiaddr. PublisherAddr multiaddr.Multiaddr `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.
func (*ProviderInfo) Deleted ¶ added in v0.4.18
func (p *ProviderInfo) Deleted() bool
func (*ProviderInfo) Inactive ¶ added in v0.4.18
func (p *ProviderInfo) Inactive() bool
func (*ProviderInfo) MarshalJSON ¶ added in v0.4.1
func (p *ProviderInfo) MarshalJSON() ([]byte, error)
func (*ProviderInfo) UnmarshalJSON ¶ added in v0.4.1
func (p *ProviderInfo) UnmarshalJSON(data []byte) error
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, discoverer 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.
func (*Registry) AllProviderInfo ¶
func (r *Registry) AllProviderInfo() []*ProviderInfo
AllProviderInfo returns information for all registered providers that are active and allowed.
func (*Registry) AllowPeer ¶ added in v0.2.0
AllowPeer configures the policy to allow messages published by the identified peer, or allow the peer to register as a provider.
func (*Registry) BlockPeer ¶ added in v0.2.0
BlockPeer configures the policy to block messages published by the identified peer, and block the peer from registering as a provider.
func (*Registry) Close ¶
Close waits for any pending discoverer to finish and then stops the registry
func (*Registry) Discover ¶
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) FilterIPsEnabled ¶ added in v0.4.21
FilterIPsEnabled returns true if IP address filtering is enabled.
func (*Registry) ImportProviders ¶ added in v0.4.17
ImportProviders reads providers from another indexer and registers any that are not already registered. Returns the count of newly registered providers.
func (*Registry) IsRegistered ¶
IsRegistered checks if the provider is in the registry
func (*Registry) ProviderInfo ¶
func (r *Registry) ProviderInfo(providerID peer.ID) (*ProviderInfo, bool)
ProviderInfo returns information for a registered provider.
func (*Registry) PublishAllowed ¶ added in v0.4.7
PublishAllowed checks if a peer is allowed to publish for other providers.
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, provider peer.AddrInfo, adID cid.Cid, publisher peer.AddrInfo) error
RegisterOrUpdate attempts to register an unregistered provider, or updates the addresses and latest advertisement of an already registered provider. If publisher has a valid ID, then the data in publisher replaces the provider's previous publisher information.
func (*Registry) RemoveProvider ¶ added in v0.4.18
func (*Registry) SyncChan ¶ added in v0.3.6
func (r *Registry) SyncChan() <-chan *ProviderInfo