core

package
v0.0.0-...-7d3eccf Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotProvided = errors.New("block not provided")

Functions

func CidFromHex

func CidFromHex(sha string) (cid.Cid, error)

func GetLocalDir

func GetLocalDir() (string, error)

func HexFromCid

func HexFromCid(cid cid.Cid) (string, error)

Types

type Fetch

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

func NewFetch

func NewFetch(gitDir string, tracker *Tracker, provider ObjectProvider) *Fetch

func (*Fetch) FetchHash

func (f *Fetch) FetchHash(base string) error

type ObjectProvider

type ObjectProvider func(cid string, tracker *Tracker) ([]byte, error)

type Push

type Push struct {
	NewNode func(hash cid.Cid, data []byte) error
	// contains filtered or unexported fields
}

func NewPush

func NewPush(gitDir string, tracker *Tracker, repo *git.Repository) *Push

func (*Push) PushHash

func (p *Push) PushHash(hash string) error

type Remote

type Remote struct {
	Logger *log.Logger

	Repo    *git.Repository
	Tracker *Tracker

	Handler RemoteHandler
	// contains filtered or unexported fields
}

func NewRemote

func NewRemote(handler RemoteHandler, reader io.Reader, writer io.Writer, logger *log.Logger) (*Remote, error)

func (*Remote) Close

func (r *Remote) Close() error

func (*Remote) NewFetch

func (r *Remote) NewFetch() *Fetch

func (*Remote) NewPush

func (r *Remote) NewPush() *Push

func (*Remote) Printf

func (r *Remote) Printf(format string, a ...interface{}) (n int, err error)

func (*Remote) ProcessCommands

func (r *Remote) ProcessCommands() error

type RemoteHandler

type RemoteHandler interface {
	List(remote *Remote, forPush bool) ([]string, error)
	Push(remote *Remote, localRef string, remoteRef string) (string, error)

	Initialize(remote *Remote) error
	Finish(remote *Remote) error

	ProvideBlock(cid string, tracker *Tracker) ([]byte, error)
}

type Tracker

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

Tracker tracks which hashes are published in IPLD

func NewTracker

func NewTracker(gitPath string) (*Tracker, error)

func (*Tracker) AddEntry

func (t *Tracker) AddEntry(hash []byte) error

func (*Tracker) Close

func (t *Tracker) Close() error

func (*Tracker) Get

func (t *Tracker) Get(refName string) ([]byte, error)

func (*Tracker) HasEntry

func (t *Tracker) HasEntry(hash []byte) (bool, error)

func (*Tracker) ListPrefixed

func (t *Tracker) ListPrefixed(prefix string) (map[string]string, error)

func (*Tracker) Set

func (t *Tracker) Set(refName string, hash []byte) error

Jump to

Keyboard shortcuts

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