pin

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version        = "1.0"
	WorkerChanSize = 8 // Max no of goroutines when walking the file tree
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is the main object which implements all things pinning.

func NewAPI

func NewAPI(lstore *localstore.DB, stateStore state.Store, params *storage.FileStoreParams, tags *chunk.Tags, api *api.API) *API

NewAPI creates a API object that is required for pinning and unpinning

func (*API) ListPins

func (p *API) ListPins() ([]PinInfo, error)

func (*API) PinFiles

func (p *API) PinFiles(addr []byte, isRaw bool, credentials string) error

PinFiles is used to pin a RAW file or a collection (which hash manifest's) to the local Swarm node. It takes the root hash as the argument and walks down the merkle tree and pin all the chunks that are encountered on the way. It pins both data chunk and tree chunks. The pre-requisite is that the file should be present in the local database. This function is called from two places 1) Just after the file is uploaded 2) anytime after uploading the file using the pin command. This function can pin both encrypted and non-encrypted files.

func (*API) UnpinFiles

func (p *API) UnpinFiles(addr []byte, credentials string) error

UnPinFiles is used to unpin an already pinned file. It takes the root hash of the file and walks down the merkle tree unpinning all the chunks that are encountered on the way. The pre-requisite is that the file should have been already pinned using the PinFiles function. This function can be called only from an external command.

type PinInfo

type PinInfo struct {
	Address    storage.Address
	IsRaw      bool
	FileSize   uint64
	PinCounter uint64
}

PinInfo is the struct that stores the information about pinned files This is stored in the state DB with Address as key

func (*PinInfo) MarshalBinary

func (f *PinInfo) MarshalBinary() (data []byte, err error)

MarshalBinary encodes the PinInfo object in to a binary form for storage

func (*PinInfo) UnmarshalBinary

func (f *PinInfo) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes the binary form from the state store to the PinInfo object

Jump to

Keyboard shortcuts

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