Documentation ¶
Overview ¶
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.
A Mirror is configurable via a set of options to control the generation of mirrored advertisements. It can be configured to simply replicate the original advertisement chain without any changes, explicitly re-sign the advertisement with the Mirror's identity, or restructure the advertisement entries entirely. Note that any change to the structure of advertisement will require the ad to be re-signed as the original signature will no longer be valid.
A Mirror will also act as a CDN for the original advertisement chain by exposing a dagsync.Publisher over GraphSync. The endpoint enables an indexer node to fetch the content associated with the original chain of advertisement as well as the mirrored advertisement chain which may be different.
Upon starting a Mirror, when no prior mirrored advertisements exist, the initial mirroring recursion depth is set to unlimited. When the initial limit is set to a value smaller than the total number of available advertisements the very first mirrored advertisement will preserve the original PreviousID link, even though the content corresponding to that link will not be hosted by the mirror.
Note that mirroring advertisements is one-to-one: for each original advertisement there will be a mirrored one. This is not affected by optional remapping of entries. Future work will provide the ability to also remap advertisements in addition to entries.
Index ¶
- type Mirror
- type Option
- func WithAlwaysReSignAds(r bool) Option
- func WithDatastore(ds datastore.Batching) Option
- func WithEntriesRecursionLimit(l selector.RecursionLimit) Option
- func WithEntryChunkRemapper(chunkSize int) Option
- func WithHamtRemapper(hashAlg multicodec.Code, bitwidth, bucketSize int) Option
- func WithHost(h host.Host) Option
- func WithInitialAdRecursionLimit(l selector.RecursionLimit) Option
- func WithPurgeCachedEntries(b bool) Option
- func WithRemappedEntriesCacheCapacity(c int) Option
- func WithSkipRemapOnEntriesTypeMatch(s bool) Option
- func WithSyncInterval(interval time.Duration) Option
- func WithTopicName(t string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mirror ¶
type Mirror struct {
// contains filtered or unexported fields
}
Mirror provides the ability to mirror the advertisement chain of an existing provider, with options to restructure entries as EntryChunk chain or HAMT.
Additionally, a mirror can also serve as a CDN for the original advertisement chain and its entries. It exposes a GraphSync publisher endpoint from which ad chain can be synced.
type Option ¶
type Option func(*options) error
func WithAlwaysReSignAds ¶
WithAlwaysReSignAds specifies whether every mirrored ad should be resigned by the mirror identity regardless of weather the advertisement content is changed as a result of mirroring or not. By default, advertisements are only re-signed if: 1) the link to previous advertisement is not changed, and 2) link to entries is not changed.
func WithDatastore ¶
func WithDatastore(ds datastore.Batching) Option
WithDatastore specifies the datastore used by the mirror to persist mirrored advertisements, their entries and other internal data. Defaults to an ephemeral in-memory datastore.
func WithEntriesRecursionLimit ¶
func WithEntriesRecursionLimit(l selector.RecursionLimit) Option
WithEntriesRecursionLimit specifies the recursion limit for syncing the advertisement entries. If unset, selector.RecursionLimitNone is used.
func WithEntryChunkRemapper ¶
WithEntryChunkRemapper remaps the entries from the original provider into schema.EntryChunkPrototype structure with the given chunk size. If unset, the original structure is mirrored without change.
See: WithSkipRemapOnEntriesTypeMatch, WithHamtRemapper.
func WithHamtRemapper ¶
WithHamtRemapper remaps the entries from the original provider into hamt.HashMapRootPrototype structure with the given bit-width and bucket size. If unset, the original structure is mirrored without change.
See: WithSkipRemapOnEntriesTypeMatch, WithEntryChunkRemapper.
func WithHost ¶
WithHost specifies the libp2p host the mirror should be exposed on. If unspecified a host with default options and random identity is used.
func WithInitialAdRecursionLimit ¶
func WithInitialAdRecursionLimit(l selector.RecursionLimit) Option
WithInitialAdRecursionLimit specifies the recursion limit for the initial sync if no previous advertisements are mirrored by the mirror. If unset, selector.RecursionLimitNone is used.
func WithPurgeCachedEntries ¶
WithPurgeCachedEntries specifies whether to delete any cached entries on start-up. This option has no effect if no entries remapper option is set.
func WithRemappedEntriesCacheCapacity ¶
WithRemappedEntriesCacheCapacity sets the LRU cache capacity used to store the remapped advertisement entries. The capacity refers to the number of complete entries DAGs cached. The actual storage occupied by the cache depends on the shape of the DAGs. See: chunker.CachedEntriesChunker.
This option has no effect if no entries remapper option is set. Defaults to 1024.
func WithSkipRemapOnEntriesTypeMatch ¶
WithSkipRemapOnEntriesTypeMatch specifies weather to skip remapping entries if the original structure prototype matches the configured remap option. Note that setting this option without setting a remap option has no effect.
See: WithEntryChunkRemapper, WithHamtRemapper.
func WithSyncInterval ¶
WithSyncInterval specifies the time interval at which the original provider is checked for new advertisements. If unset, the default time interval of 10 minutes is used.
func WithTopicName ¶
WithTopicName specifies the topi name on which the mirrored advertisements are announced.