mirror

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0, MIT Imports: 37 Imported by: 0

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

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.

func New

func New(ctx context.Context, source peer.AddrInfo, o ...Option) (*Mirror, error)

New instantiates a new Mirror that mirrors ad chain from the given source provider.

See: Mirror.Start, Mirror.Shutdown.

func (*Mirror) PublisherAddrs added in v0.13.6

func (m *Mirror) PublisherAddrs() []multiaddr.Multiaddr

func (*Mirror) Shutdown

func (m *Mirror) Shutdown() error

func (*Mirror) Start

func (m *Mirror) Start() error

type Option

type Option func(*options) error

func WithAlwaysReSignAds

func WithAlwaysReSignAds(r bool) Option

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(limit int64) Option

WithEntriesRecursionLimit specifies the recursion limit for syncing the advertisement entries.

There is no recursion limit if unset.

func WithEntryChunkRemapper

func WithEntryChunkRemapper(chunkSize int) Option

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 WithHTTPListenAddr added in v0.13.6

func WithHTTPListenAddr(addr string) Option

WithHTTPListenAddr sets the HTTP address:port for the http publisher to listen on.

func WithHamtRemapper

func WithHamtRemapper(hashAlg multicodec.Code, bitwidth, bucketSize int) Option

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

func WithHost(h host.Host, privKey p2pcrypto.PrivKey) Option

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(limit int64) Option

WithInitialAdRecursionLimit specifies the recursion limit for the initial sync if no previous advertisements are mirrored by the mirror.

There is no recursion limit if unset.

func WithPurgeCachedEntries

func WithPurgeCachedEntries(b bool) Option

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

func WithRemappedEntriesCacheCapacity(c int) Option

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

func WithSkipRemapOnEntriesTypeMatch(s bool) Option

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

func WithSyncInterval(interval time.Duration) Option

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

func WithTopicName(t string) Option

WithTopicName specifies the topi name on which the mirrored advertisements are announced.

Jump to

Keyboard shortcuts

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