ipnisync

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0, MIT Imports: 28 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IpniPath = path.Join("/ipni", protoVersion, "ad")

Functions

This section is empty.

Types

type Option

type Option func(*config) error

Option is a function that sets a value in a config.

func WithHandlerPath

func WithHandlerPath(urlPath string) Option

WithHandlerPath sets the path used to handle requests to this publisher. This should only include the path before the /ipni/v1/ad/ part of the path.

func WithHeadTopic

func WithHeadTopic(topic string) Option

WithHeadTopic sets the optional topic returned in a head query response. This is the topic on which advertisement are announced.

func WithServer

func WithServer(serve bool) Option

WithServer, if true, starts an http server listening on the given address. an HTTP server. If this option is not specified, then no server is started and this will need to be done by the caller.

type Publisher

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

Publisher serves an advertisement chain over HTTP.

func NewPublisher

func NewPublisher(address string, lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (*Publisher, error)

NewPublisher creates a new http publisher. It is optional with start a server, listening on the specified address, using the WithStartServer option.

func NewPublisherForListener

func NewPublisherForListener(listener net.Listener, handlerPath string, lsys ipld.LinkSystem, privKey ic.PrivKey) (*Publisher, error)

NewPublisherForListener creates a new http publisher for an existing listener. When providing an existing listener, running the HTTP server is the caller's responsibility. ServeHTTP on the returned Publisher can be used to handle requests. handlerPath is the path to handle requests on, e.g. "ipni" for `/ipni/...` requests.

DEPRECATED: use NewPublisherWithoutServer(listener.Addr(), ...)

func NewPublisherWithoutServer

func NewPublisherWithoutServer(address, handlerPath string, lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (*Publisher, error)

NewPublisherWithoutServer creates a new http publisher for an existing network address. When providing an existing network address, running the HTTP server is the caller's responsibility. ServeHTTP on the returned Publisher can be used to handle requests.

DEPRECATED: use NewPublisher(address, lsys, privKey, WithHandlerPath(handlerPath))

func (*Publisher) Addrs

func (p *Publisher) Addrs() []multiaddr.Multiaddr

Addrs returns the addresses, as []multiaddress, that the Publisher is listening on.

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes the Publisher.

func (*Publisher) ID

func (p *Publisher) ID() peer.ID

ID returns the p2p peer ID of the Publisher.

func (*Publisher) Protocol

func (p *Publisher) Protocol() int

Protocol returns the multihash protocol ID of the transport used by the publisher.

func (*Publisher) ServeHTTP

func (p *Publisher) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

func (*Publisher) SetRoot

func (p *Publisher) SetRoot(c cid.Cid)

SetRoot sets the head of the advertisement chain.

type Sync

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

Sync provides sync functionality for use with all http syncs.

func NewSync

func NewSync(lsys ipld.LinkSystem, client *http.Client, blockHook func(peer.ID, cid.Cid)) *Sync

NewSync creates a new Sync.

func (*Sync) Close

func (s *Sync) Close()

func (*Sync) NewSyncer

func (s *Sync) NewSyncer(peerID peer.ID, peerAddrs []multiaddr.Multiaddr) (*Syncer, error)

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 provides sync functionality for a single sync with a peer.

func (*Syncer) GetHead

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

GetHead fetches the head of the peer's advertisement chain.

func (*Syncer) Sync

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

Sync syncs the peer's advertisement chain or entries chain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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