ipfs

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 31 Imported by: 1

README

ipfs-tools

Tools for IPFS

Documentation

Overview

Package ipfs is a generated GoMock package.

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 IPool added in v0.0.5

type IPool interface {
	Get(ctx context.Context, link string) (Data, error)
	GetFromRandomGateway(ctx context.Context, link string) (Data, error)
	GetFromNode(ctx context.Context, link, node string) (Data, error)
}

type MockIPool added in v0.0.5

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

MockIPool is a mock of IPool interface.

func NewMockIPool added in v0.0.5

func NewMockIPool(ctrl *gomock.Controller) *MockIPool

NewMockIPool creates a new mock instance.

func (*MockIPool) EXPECT added in v0.0.5

func (m *MockIPool) EXPECT() *MockIPoolMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIPool) Get added in v0.0.5

func (m *MockIPool) Get(ctx context.Context, link string) (Data, error)

Get mocks base method.

func (*MockIPool) GetFromNode added in v0.0.5

func (m *MockIPool) GetFromNode(ctx context.Context, link, node string) (Data, error)

GetFromNode mocks base method.

func (*MockIPool) GetFromRandomGateway added in v0.0.5

func (m *MockIPool) GetFromRandomGateway(ctx context.Context, link string) (Data, error)

GetFromRandomGateway mocks base method.

type MockIPoolGetCall added in v0.0.5

type MockIPoolGetCall struct {
	*gomock.Call
}

MockIPoolGetCall wrap *gomock.Call

func (*MockIPoolGetCall) Do added in v0.0.5

Do rewrite *gomock.Call.Do

func (*MockIPoolGetCall) DoAndReturn added in v0.0.5

func (c *MockIPoolGetCall) DoAndReturn(f func(context.Context, string) (Data, error)) *MockIPoolGetCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockIPoolGetCall) Return added in v0.0.5

func (c *MockIPoolGetCall) Return(arg0 Data, arg1 error) *MockIPoolGetCall

Return rewrite *gomock.Call.Return

type MockIPoolGetFromNodeCall added in v0.0.5

type MockIPoolGetFromNodeCall struct {
	*gomock.Call
}

MockIPoolGetFromNodeCall wrap *gomock.Call

func (*MockIPoolGetFromNodeCall) Do added in v0.0.5

Do rewrite *gomock.Call.Do

func (*MockIPoolGetFromNodeCall) DoAndReturn added in v0.0.5

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockIPoolGetFromNodeCall) Return added in v0.0.5

Return rewrite *gomock.Call.Return

type MockIPoolGetFromRandomGatewayCall added in v0.0.5

type MockIPoolGetFromRandomGatewayCall struct {
	*gomock.Call
}

MockIPoolGetFromRandomGatewayCall wrap *gomock.Call

func (*MockIPoolGetFromRandomGatewayCall) Do added in v0.0.5

Do rewrite *gomock.Call.Do

func (*MockIPoolGetFromRandomGatewayCall) DoAndReturn added in v0.0.5

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockIPoolGetFromRandomGatewayCall) Return added in v0.0.5

Return rewrite *gomock.Call.Return

type MockIPoolMockRecorder added in v0.0.5

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

MockIPoolMockRecorder is the mock recorder for MockIPool.

func (*MockIPoolMockRecorder) Get added in v0.0.5

func (mr *MockIPoolMockRecorder) Get(ctx, link any) *MockIPoolGetCall

Get indicates an expected call of Get.

func (*MockIPoolMockRecorder) GetFromNode added in v0.0.5

func (mr *MockIPoolMockRecorder) GetFromNode(ctx, link, node any) *MockIPoolGetFromNodeCall

GetFromNode indicates an expected call of GetFromNode.

func (*MockIPoolMockRecorder) GetFromRandomGateway added in v0.0.5

func (mr *MockIPoolMockRecorder) GetFromRandomGateway(ctx, link any) *MockIPoolGetFromRandomGatewayCall

GetFromRandomGateway indicates an expected call of GetFromRandomGateway.

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 `validate:"required" yaml:"id"`
	Address string `validate:"required" yaml:"addr"`
}

Provider -

Jump to

Keyboard shortcuts

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