ipfs

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnouncementAddresses

func AnnouncementAddresses() ([]multiaddr.Multiaddr, error)

Types

type Node

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

A Node is a minimal IPFS node

func NewNode

func NewNode(ctx core.Context, cfg *config.Config, rs ReprovideStore, ds datastore.Batching, bs blockstore.Blockstore) (*Node, error)

NewNode creates a new IPFS node

func (*Node) AddBlock

func (n *Node) AddBlock(ctx context.Context, block blocks.Block) error

AddBlock adds a generic block to the IPFS node

func (*Node) AddPeer

func (n *Node) AddPeer(addr peer.AddrInfo)

AddPeer adds a peer to the peerstore

func (*Node) Close

func (n *Node) Close() error

Close closes the node

func (*Node) ConnectionAddresses

func (n *Node) ConnectionAddresses() ([]multiaddr.Multiaddr, error)

func (*Node) GetBlock

func (n *Node) GetBlock(ctx context.Context, c cid.Cid) (format.Node, error)

GetBlock fetches a block from the IPFS network

func (*Node) HasBlock

func (n *Node) HasBlock(ctx context.Context, c cid.Cid) (bool, error)

HasBlock checks if a block is locally pinned

func (*Node) PeerID

func (n *Node) PeerID() peer.ID

PeerID returns the peer ID of the node

func (*Node) Peers

func (n *Node) Peers() []peer.ID

Peers returns the list of peers in the routing table

func (*Node) Pin

func (n *Node) Pin(ctx context.Context, root cid.Cid, recursive bool) error

Pin pins a CID

func (*Node) TriggerReprovider

func (n *Node) TriggerReprovider()

type PinnedCID

type PinnedCID struct {
	CID              cid.Cid   `json:"cid"`
	LastAnnouncement time.Time `json:"lastAnnouncement"`
}

PinnedCID is a CID that needs to be periodically announced.

type Provider

type Provider interface {
	provider.Ready
	provider.ProvideMany
}

A Provider provides CIDs to the IPFS network.

type ReprovideStore

type ReprovideStore interface {
	ProvideCIDs(limit int) ([]PinnedCID, error)
	SetLastAnnouncement(cids []cid.Cid, t time.Time) error
}

A ReprovideStore stores CIDs that need to be periodically announced.

type Reprovider

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

A Reprovider periodically announces CIDs to the IPFS network.

func NewReprovider

func NewReprovider(provider Provider, store ReprovideStore, log *zap.Logger) *Reprovider

NewReprovider creates a new reprovider.

func (*Reprovider) Run

func (r *Reprovider) Run(ctx context.Context, interval, timeout time.Duration, batchSize int)

Run starts the reprovider loop, which periodically announces CIDs that have not been announced in the last interval.

func (*Reprovider) Trigger

func (r *Reprovider) Trigger()

Trigger triggers the reprovider loop to run immediately.

Jump to

Keyboard shortcuts

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