ipfs

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 27 Imported by: 0

README

ipfs-tools

Tools for IPFS

Documentation

Index

Constants

View Source
const (
	IpfsLinkPrefix = "ipfs://"
)

prefix

Variables

View Source
var (
	ErrInvalidURI           = errors.New("invalid URI")
	ErrEmptyIPFSGatewayList = errors.New("empty IPFS gateway list")
	ErrHTTPRequest          = errors.New("HTTP request error")
	ErrJSONDecoding         = errors.New("JSON decoding error")
	ErrNoIPFSResponse       = errors.New("can't load document from IPFS")
	ErrInvalidCID           = errors.New("invalid CID")
)

Errors

Functions

func FindAllLinks(data []byte) []string

FindAllLinks -

func Hash

func Hash(link string) (string, error)

Hash - separate IPFS hash from link

func Is

func Is(link string) bool

Is -

func Link(gateway, hash string) string

Link - get gateway link

func Path

func Path(link string) string

Path - get path without protocol

func ShuffleGateways

func ShuffleGateways(gateways []string) []string

ShuffleGateways - shuffle gateways for different request order for different files

Types

type Data

type Data struct {
	Raw          []byte
	Node         string
	ResponseTime int64
}

Data -

type Node

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

Node -

func NewNode

func NewNode(ctx context.Context, dir string, limit int64, blacklist []string, providers []Provider) (*Node, error)

NewNode -

func (*Node) Close

func (n *Node) Close() error

Close -

func (*Node) Get

func (n *Node) Get(ctx context.Context, cid string) (Data, error)

Get -

func (*Node) Start

func (n *Node) Start(ctx context.Context, bootstrap ...string) error

Start -

type Pool

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

Pool -

func NewPool

func NewPool(gateways []string, limit int64) (*Pool, error)

NewPool -

func (*Pool) Get

func (pool *Pool) Get(ctx context.Context, link string) (Data, error)

Get - returns result if one of node returns it

func (*Pool) GetFromNode

func (pool *Pool) GetFromNode(ctx context.Context, link, node string) (Data, error)

GetFromNode - returns result if `node` returns it

func (*Pool) GetFromRandomGateway

func (pool *Pool) GetFromRandomGateway(ctx context.Context, link string) (Data, error)

GetFromRandomGateway - returns result if random node returns it

type Provider

type Provider struct {
	ID      string `yaml:"id" validate:"required"`
	Address string `yaml:"addr" validate:"required"`
}

Provider -

Jump to

Keyboard shortcuts

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