start

package
v0.0.0-...-62f7a63 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const GatewayURLReplaceStr = "{cid}"
View Source
const InfuraTargetName = "infura"
View Source
const PinataTargetName = "pinata"
View Source
const Web3TargetName = "web3"

Variables

View Source
var PinningServiceTargetConstructors = map[string]PinningServiceTargetConstructor{
	InfuraTargetName: NewInfura,
	PinataTargetName: NewPinata,
}
View Source
var UploadServiceTargetConstructors = map[string]UploadServiceTargetConstructor{
	Web3TargetName: NewWeb3,
}

Functions

This section is empty.

Types

type CleanupTarget

type CleanupTarget interface {
	Target
	CleanUp(ctx context.Context, c cid.Cid) error
}

type DummyTarget

type DummyTarget struct{}

DummyTarget is here to detect peers that sniff DHT traffic. No one should ever request data provided by this target.

func NewDummyTarget

func NewDummyTarget() *DummyTarget

func (*DummyTarget) Backoff

func (dt *DummyTarget) Backoff(ctx context.Context) backoff.BackOff

func (*DummyTarget) CleanUp

func (dt *DummyTarget) CleanUp(ctx context.Context, c cid.Cid) error

func (*DummyTarget) Name

func (dt *DummyTarget) Name() string

func (*DummyTarget) Operation

func (dt *DummyTarget) Operation(ctx context.Context, c cid.Cid) error

func (*DummyTarget) Rate

func (dt *DummyTarget) Rate() time.Duration

func (*DummyTarget) Timeout

func (dt *DummyTarget) Timeout() time.Duration

func (*DummyTarget) Type

func (dt *DummyTarget) Type() string

type Gateway

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

func NewGatewayTarget

func NewGatewayTarget(name string, urlFmt string) *Gateway

func (*Gateway) Backoff

func (g *Gateway) Backoff(ctx context.Context) backoff.BackOff

func (*Gateway) CleanUp

func (g *Gateway) CleanUp(ctx context.Context, c cid.Cid) error

func (*Gateway) Name

func (g *Gateway) Name() string

func (*Gateway) Operation

func (g *Gateway) Operation(ctx context.Context, c cid.Cid) error

func (*Gateway) Rate

func (g *Gateway) Rate() time.Duration

func (*Gateway) Timeout

func (g *Gateway) Timeout() time.Duration

func (*Gateway) Type

func (g *Gateway) Type() string

type Infura

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

func (*Infura) Backoff

func (i *Infura) Backoff(ctx context.Context) backoff.BackOff

func (*Infura) CleanUp

func (i *Infura) CleanUp(ctx context.Context, c cid.Cid) error

func (*Infura) Name

func (i *Infura) Name() string

func (*Infura) Operation

func (i *Infura) Operation(ctx context.Context, c cid.Cid) error

func (*Infura) Rate

func (i *Infura) Rate() time.Duration

func (*Infura) Timeout

func (i *Infura) Timeout() time.Duration

func (*Infura) Type

func (i *Infura) Type() string

type Payload

type Payload struct {
	Message   string
	Timestamp time.Time
	Random    []byte
	Signature []byte
}

Payload is the underlying data that gets announced to the network

func NewPayload

func NewPayload(key crypto.PrivKey) (*Payload, error)

NewPayload generates 100 bytes of random data and initializes a Payload data structure. It's also signing the data for no reason.

func (*Payload) Bytes

func (p *Payload) Bytes() ([]byte, error)

Bytes returns the json representation of the data embedded into a DAG node so that IPFS can make sense of the data.

func (*Payload) JsonBytes

func (p *Payload) JsonBytes() ([]byte, error)

JsonBytes returns the json representation of the data.

type PinProbe

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

type PinTarget

type PinTarget interface {
	Target
	Operation(ctx context.Context, c cid.Cid) error
}

func NewInfura

func NewInfura(h host.Host, auth string) (PinTarget, error)

func NewPinata

func NewPinata(h host.Host, auth string) (PinTarget, error)

type Pinata

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

func (*Pinata) Backoff

func (p *Pinata) Backoff(ctx context.Context) backoff.BackOff

func (*Pinata) CleanUp

func (p *Pinata) CleanUp(ctx context.Context, c cid.Cid) error

func (*Pinata) Name

func (p *Pinata) Name() string

func (*Pinata) Operation

func (p *Pinata) Operation(ctx context.Context, c cid.Cid) error

func (*Pinata) Rate

func (p *Pinata) Rate() time.Duration

func (*Pinata) Timeout

func (p *Pinata) Timeout() time.Duration

func (*Pinata) Type

func (p *Pinata) Type() string

type PinataMetadata

type PinataMetadata struct {
	Name string `json:"name"`
}

type PinataOptions

type PinataOptions struct {
	HostNodes []string `json:"hostNodes"`
}

type PinataRequest

type PinataRequest struct {
	HashToPin      string          `json:"hashToPin"`
	PinataMetadata *PinataMetadata `json:"pinataMetadata,omitempty"`
	PinataOptions  *PinataOptions  `json:"pinataOptions,omitempty"`
}

type PinningServiceTargetConstructor

type PinningServiceTargetConstructor = func(host host.Host, auth string) (PinTarget, error)

type Probe

type Probe interface {
	// contains filtered or unexported methods
}

type Scheduler

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

The Scheduler is responsible for the initialization of Targets and Probes. Targets are entities like gateways or pinning services. Probes can be configured with a specific Target and carry out the publication of content and later the request through the Target. After all targets are initialized from the configuration, they get assigned a PinProbe. These probes are then instructed to start doing their thing - which means, announcing CIDs to the DHT and then requesting it through the associated target.

func NewScheduler

func NewScheduler(ctx context.Context, conf *config.Config, dbc *db.Client, mmc *maxmind.Client) (*Scheduler, error)

NewScheduler initializes a new libp2p host with the given configuration handles to a persistent storage and Maxmind GeoIP2 database.

func (*Scheduler) StartProbes

func (s *Scheduler) StartProbes(ctx context.Context) error

StartProbes connects to the IPFS bootstrap peers and starts each target probe in their own go-routine.

type Target

type Target interface {
	Backoff(ctx context.Context) backoff.BackOff
	Timeout() time.Duration
	Rate() time.Duration
	Name() string
	Type() string
}

type Throttle

type Throttle struct {
	C <-chan time.Time // The channel on which the leases are delivered.
	// contains filtered or unexported fields
}

func NewThrottle

func NewThrottle(x int, duration time.Duration) *Throttle

NewThrottle returns a new Throttle containing a channel that will send the time x number of times within a period specified by the duration argument. It drops leases to make up for slow receivers. The duration must be greater than zero; if not, NewThrottle will panic. Stop the throttle to release associated resources and close its channel.

func (*Throttle) Stop

func (t *Throttle) Stop()

Stop turns off a throttle. After Stop, no more leases will be sent. Stop closes the channel.

type Tracer

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

func NewTracer

func NewTracer() *Tracer

func (*Tracer) MessageReceived

func (t *Tracer) MessageReceived(id peer.ID, msg message.BitSwapMessage)

func (*Tracer) MessageSent

func (t *Tracer) MessageSent(id peer.ID, msg message.BitSwapMessage)

func (*Tracer) Register

func (t *Tracer) Register(contentID cid.Cid) <-chan peer.ID

func (*Tracer) Unregister

func (t *Tracer) Unregister(contentID cid.Cid)

type UploadProbe

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

type UploadServiceTargetConstructor

type UploadServiceTargetConstructor = func(host host.Host, auth string) (UploadTarget, error)

type UploadTarget

type UploadTarget interface {
	Target
	UploadContent(ctx context.Context, block *blocks.BasicBlock) error
}

func NewWeb3

func NewWeb3(h host.Host, auth string) (UploadTarget, error)

type Web3

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

func (*Web3) Backoff

func (t *Web3) Backoff(ctx context.Context) backoff.BackOff

func (*Web3) CleanUp

func (t *Web3) CleanUp(ctx context.Context, c cid.Cid) error

func (*Web3) Name

func (t *Web3) Name() string

func (*Web3) Rate

func (t *Web3) Rate() time.Duration

func (*Web3) Timeout

func (t *Web3) Timeout() time.Duration

func (*Web3) Type

func (t *Web3) Type() string

func (*Web3) UploadContent

func (t *Web3) UploadContent(ctx context.Context, block *blocks.BasicBlock) error

type Web3UploadResponse

type Web3UploadResponse struct {
	Cid    string `json:"cid"`
	CarCid string `json:"carCid"`
}

Jump to

Keyboard shortcuts

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