Documentation ¶
Overview ¶
Package provider represents a reference implementation of an index provider. It integrates with the indexer node protocol, "storetheinex" in order to advertise the availability of a list of multihashes as an IPLD DAG. For the complete advertisement IPLD schema, see:
A reference implementation of provider.Interface can be found in engine.Engine.
Index ¶
- Variables
- type Interface
- type MultihashIterator
- func CarMultihashIterator(idx carindex.IterableIndex) (MultihashIterator, error)
- func EntryChunkMultihashIterator(l ipld.Link, ls ipld.LinkSystem) (MultihashIterator, error)
- func HamtMultihashIterator(root *hamt.HashMapRoot, ls ipld.LinkSystem) MultihashIterator
- func SliceMultihashIterator(mhs []multihash.Multihash) MultihashIterator
- type MultihashLister
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMultihashLister signals that no provider.MultihashLister is registered for lookup. ErrNoMultihashLister = errors.New("no multihash lister is registered") // ErrContextIDNotFound signals that no item is associated to the given context ID. ErrContextIDNotFound = errors.New("context ID not found") // ErrAlreadyAdvertised signals that an advertisement for identical content was already // published. ErrAlreadyAdvertised = errors.New("advertisement already published") )
var Version = buildVersion()
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { // PublishLocal appends adv to the locally stored advertisement chain and // returns the corresponding CID to it. This function does not publish the // changes to the advertisement chain onto gossip pubsub channel. Use // Publish instead if indexer nodes must be made aware of the appended // advertisement. // // See: Publish. PublishLocal(context.Context, schema.Advertisement) (cid.Cid, error) // Publish appends adv to the locally stored advertisement chain, and // publishes the new advertisement onto gossip pubsub. The CID returned // represents the ID of the advertisement appended to the chain. Publish(context.Context, schema.Advertisement) (cid.Cid, error) // RegisterMultihashLister registers the hook that is used by the provider to look up // a list of multihashes by context ID. Only a single registration is // supported; repeated calls to this function will replace the previous // registration. RegisterMultihashLister(MultihashLister) // NotifyPut signals the provider that the list of multihashes looked up by // the given provider and contextIDs is available. The given // provider and contextIDs are then used to look up the list of multihashes via MultihashLister. // An advertisement is then generated, appended to the chain of advertisements and published onto // the gossip pubsub channel. Advertisements for different provider IDs are placed onto the same chain. // Use an empty provider string for the default configured provider. // // A MultihashLister must be registered prior to using this function. // ErrNoMultihashLister is returned if no such lister is registered. // // The metadata is data that provides hints about how to retrieve data and // is protocol dependant. The metadata must at least specify a protocol // ID, but its data is optional. // // If provider, contextID and metadata are the same as a previous call to // NotifyPut, then ErrAlreadyAdvertised is returned. // // If provider is nil then the default configured provider will be assumed. // // This function returns the ID of the advertisement published. NotifyPut(ctx context.Context, provider *peer.AddrInfo, contextID []byte, md metadata.Metadata) (cid.Cid, error) // NotifyRemove signals to the provider that the multihashes that // corresponded to the given provider and contextID are no longer available. An advertisement // is then generated, appended to the chain of advertisements and published // onto the gossip pubsub channel. // The given provider and contextID tuple must have previously been put via NotifyPut. // If not found ErrContextIDNotFound is returned. // // If providerID is empty then the default configured provider will be assumed. // // This function returns the ID of the advertisement published. NotifyRemove(ctx context.Context, providerID peer.ID, contextID []byte) (cid.Cid, error) // GetAdv gets the advertisement that corresponds to the given cid. GetAdv(context.Context, cid.Cid) (*schema.Advertisement, error) // GetLatestAdv gets the latest advertisement on this provider's // advertisement chain and the CID to which it corresponds. GetLatestAdv(context.Context) (cid.Cid, *schema.Advertisement, error) // Shutdown shuts down this provider, and blocks until all resources // occupied by it are discarded. After calling this function the provider // is no longer available for use. Shutdown() error }
Interface represents an index provider that manages the advertisement for multihashes to indexer nodes.
type MultihashIterator ¶
type MultihashIterator interface { // Next returns the next multihash in the list of mulitihashes. The // iterator fails fast: errors that occur during iteration are returned // immediately. This function returns a zero multihash and io.EOF when // there are no more elements to return. Next() (multihash.Multihash, error) }
MultihashIterator iterates over a list of multihashes.
See: CarMultihashIterator.
func CarMultihashIterator ¶
func CarMultihashIterator(idx carindex.IterableIndex) (MultihashIterator, error)
CarMultihashIterator constructs a new MultihashIterator from a CAR index.
This iterator supplies multihashes in deterministic order of their corresponding CAR offset. The order is maintained consistently regardless of the underlying IterableIndex implementation. Returns error if duplicate offsets detected.
func EntryChunkMultihashIterator ¶
func EntryChunkMultihashIterator(l ipld.Link, ls ipld.LinkSystem) (MultihashIterator, error)
EntryChunkMultihashIterator constructs a MultihashIterator that iterates over the global list of chained multihashes starting from the given link. It dynamically loads the next EntryChunk from the given ipld.LinkSystem as needed.
func HamtMultihashIterator ¶
func HamtMultihashIterator(root *hamt.HashMapRoot, ls ipld.LinkSystem) MultihashIterator
HamtMultihashIterator constructs a MultihashIterator backed by the given root HAMT. The links from root are dynamically loaded as needed using the given link system.
func SliceMultihashIterator ¶
func SliceMultihashIterator(mhs []multihash.Multihash) MultihashIterator
SliceMultihashIterator constructs a new MultihashIterator from a slice of multihashes.
type MultihashLister ¶
type MultihashLister func(ctx context.Context, provider peer.ID, contextID []byte) (MultihashIterator, error)
MultihashLister lists the multihashes that correspond to a given provider and contextID. The lister must be deterministic: it must produce the same list of multihashes in the same order for the same (provider, contextID) tuple.
empty provider means falling back to the default. See: Interface.NotifyPut, Interface.NotifyRemove, MultihashIterator.
Directories ¶
Path | Synopsis |
---|---|
Package cardatatransfer privdes a datatransfer server that can be used to retrieve multihashes supplied via engine.Engine and supplier.CarSupplier as the provider.MultihashLister.
|
Package cardatatransfer privdes a datatransfer server that can be used to retrieve multihashes supplied via engine.Engine and supplier.CarSupplier as the provider.MultihashLister. |
stores
Package stores is copy pasted from go-fil-markets stores package - there is no novel code here.
|
Package stores is copy pasted from go-fil-markets stores package - there is no novel code here. |
cmd
|
|
provider
Provider CLI can be used to start an index-provider daemon that runs a reference implementation of the provider interface, with ability to publish advertisements by importing/removing CAR files and server content retrieval via DataTransfer GraphSync protocol.
|
Provider CLI can be used to start an index-provider daemon that runs a reference implementation of the provider interface, with ability to publish advertisements by importing/removing CAR files and server content retrieval via DataTransfer GraphSync protocol. |
Package engine provides a reference implementation of the provider.Interface in order to advertise the availability of a list of multihashes to indexer nodes such as "storetheindex".
|
Package engine provides a reference implementation of the provider.Interface in order to advertise the availability of a list of multihashes to indexer nodes such as "storetheindex". |
chunker
Package chunker provides functionality for chunking ad entries generated from provider.MultihashIterator into an IPLD DAG.
|
Package chunker provides functionality for chunking ad entries generated from provider.MultihashIterator into an IPLD DAG. |
peerutil
Package peerutil provides utilities around peer ID values.
|
Package peerutil provides utilities around peer ID values. |
xproviders
Package xproviders provides convinience classes for building and signing advertisements with ExtendedProviders, that implement extended providers specification.
|
Package xproviders provides convinience classes for building and signing advertisements with ExtendedProviders, that implement extended providers specification. |
Package mirror provides the ability to replicate the advertisement chain from an existing provider with options to restructure the advertisement entries into schema.EntryChunk or HAMT.
|
Package mirror provides the ability to replicate the advertisement chain from an existing provider with options to restructure the advertisement entries into schema.EntryChunk or HAMT. |
Package mock_provider is a generated GoMock package.
|
Package mock_provider is a generated GoMock package. |
server
|
|
admin/http
Package adminserver provides a HTTP server that allows to perform administrative operations.
|
Package adminserver provides a HTTP server that allows to perform administrative operations. |
Package supplier provides mechanisms to supply mulithashes to an index-provider engine via provider.MultihashLister The only implemented mechanism is CarSupplier, that in conjunction with an engine allows a user to advertise multihashes by simply providing CAR files.
|
Package supplier provides mechanisms to supply mulithashes to an index-provider engine via provider.MultihashLister The only implemented mechanism is CarSupplier, that in conjunction with an engine allows a user to advertise multihashes by simply providing CAR files. |