dtsync

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0, MIT Imports: 38 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadEncoding = errors.New("invalid message encoding")

Functions

func NewPublisher

func NewPublisher(host host.Host, ds datastore.Batching, lsys ipld.LinkSystem, topic string, options ...Option) (*publisher, error)

NewPublisher creates a new legs publisher

func NewPublisherFromExisting

func NewPublisherFromExisting(dtManager dt.Manager, host host.Host, topic string, lsys ipld.LinkSystem, options ...Option) (*publisher, error)

NewPublisherFromExisting instantiates go-legs publishing on an existing data transfer instance

Types

type Message

type Message struct {
	Cid       cid.Cid
	Addrs     [][]byte
	ExtraData []byte
	// The OrigPeer field may or may not be present in the serialized data, and
	// the CBOR serializer/deserializer is able to detect that. Only messages
	// that are re-published by an indexer, for consumption by othen indexers,
	// contain this field.
	OrigPeer string
}

Message is the payload of a gossip pubsub message.

func (*Message) GetAddrs added in v0.3.0

func (m *Message) GetAddrs() ([]multiaddr.Multiaddr, error)

GetAddrs reads the slice of Multiaddr that is stored in the Message as a slice of []byte.

func (*Message) MarshalCBOR added in v0.3.0

func (t *Message) MarshalCBOR(w io.Writer) error

func (*Message) SetAddrs added in v0.3.0

func (m *Message) SetAddrs(addrs []multiaddr.Multiaddr)

SetAddrs writes a slice of Multiaddr into the Message as a slice of []byte.

func (*Message) UnmarshalCBOR added in v0.3.0

func (t *Message) UnmarshalCBOR(r io.Reader) error

type Option

type Option func(*config) error

func AllowPeer added in v0.3.14

func AllowPeer(allowPeer func(peer.ID) bool) Option

AllowPeer sets the function that determines whether to allow or reject graphsync sessions from a peer.

func Topic

func Topic(topic *pubsub.Topic) Option

Topic provides an existing pubsub topic.

func WithExtraData added in v0.2.8

func WithExtraData(data []byte) Option

WithExtraData sets the extra data to include in the pubsub message.

type Sync

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

Sync provides sync functionality for use with all datatransfer syncs.

func NewSync

func NewSync(host host.Host, ds datastore.Batching, lsys ipld.LinkSystem, blockHook func(peer.ID, cid.Cid)) (*Sync, error)

NewSync creates a new Sync with its own datatransfer.Manager.

func NewSyncWithDT added in v0.2.1

func NewSyncWithDT(host host.Host, dtManager dt.Manager, gs graphsync.GraphExchange, ls *ipld.LinkSystem, blockHook func(peer.ID, cid.Cid)) (*Sync, error)

NewSyncWithDT creates a new Sync with a datatransfer.Manager provided by the caller.

func (*Sync) Close

func (s *Sync) Close() error

Close unregisters datatransfer event notification. If this Sync owns the datatransfer.Manager then the Manager is stopped.

func (*Sync) NewSyncer

func (s *Sync) NewSyncer(peerID peer.ID, topicName string, rateLimiter *rate.Limiter) *Syncer

NewSyncer creates a new Syncer to use for a single sync operation against a peer.

type Syncer

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

Syncer handles a single sync with a provider.

func (*Syncer) GetHead

func (s *Syncer) GetHead(ctx context.Context) (cid.Cid, error)

GetHead queries a provider for the latest CID.

func (*Syncer) Sync

func (s *Syncer) Sync(ctx context.Context, nextCid cid.Cid, sel ipld.Node) error

Sync opens a datatransfer data channel and uses the selector to pull data from the provider.

type Voucher

type Voucher struct {
	Head *cid.Cid
}

A Voucher is used to communicate a new DAG head

func (*Voucher) MarshalCBOR

func (t *Voucher) MarshalCBOR(w io.Writer) error

func (*Voucher) Type

Type provides an identifier for the voucher to go-data-transfer

func (*Voucher) UnmarshalCBOR

func (t *Voucher) UnmarshalCBOR(r io.Reader) error

type VoucherResult

type VoucherResult struct {
	Code uint64
}

A VoucherResult responds to a voucher

func (*VoucherResult) MarshalCBOR

func (t *VoucherResult) MarshalCBOR(w io.Writer) error

func (*VoucherResult) Type

Type provides an identifier for the voucher result to go-data-transfer

func (*VoucherResult) UnmarshalCBOR

func (t *VoucherResult) UnmarshalCBOR(r io.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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