pinstore

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pin

type Pin struct {
	APIID     ffs.APIID
	Staged    bool
	CreatedAt int64
}

Pin describes a pin of a Cid from a APIID. The Stage field indicates if the pin is a stage-pin.

type PinnedCid

type PinnedCid struct {
	Cid  cid.Cid
	Pins []Pin
}

PinnedCid contains information about a pinned Cid from multiple APIIDs.

type Store

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

Store saves information about pinned Cids per APIID. It can be understood as the pinset for a set of APIIDs. There're two types of pins: stage-pins and full-pins. Stage-pins indicate a form of soft-pinning that clients might use as an indication of unpinnable Cids by GC processes.

func New

func New(ds datastore.TxnDatastore) (*Store, error)

New returns a new Store.

func (*Store) Add

func (s *Store) Add(iid ffs.APIID, c cid.Cid) error

Add marks c as fully-pinned by iid. If c is already stage-pinned, then is switched to fully-pinned. If c is already fully-pinned, then only its timestamp gets refreshed.

func (*Store) AddStaged

func (s *Store) AddStaged(iid ffs.APIID, c cid.Cid) error

AddStaged pins a Cid for APIID with a staged-pin. If c is already stage-pinned, its stage-pin timestamp will be refreshed. If c is already fully-pinned, this call is a noop (full-pin will be kept).

func (*Store) GetAll

func (s *Store) GetAll() ([]PinnedCid, error)

GetAll returns all pinned cids.

func (*Store) GetAllOnlyStaged

func (s *Store) GetAllOnlyStaged() ([]PinnedCid, error)

GetAllOnlyStaged returns all cids that only have stage-pins.

func (*Store) IsPinned

func (s *Store) IsPinned(c cid.Cid) bool

IsPinned returns true if c is pinned by at least one APIID.

func (*Store) IsPinnedBy

func (s *Store) IsPinnedBy(iid ffs.APIID, c cid.Cid) bool

IsPinnedBy returns true if the Cid is pinned for APIID. Both strong and staged pins are considered.

func (*Store) RefCount

func (s *Store) RefCount(c cid.Cid) (int, int)

RefCount returns two integers (total, staged). total is the total number of ref counts for the Cid. staged is the total number of ref counts corresponding to staged pins. total includes staged, this means that: * total >= staged * non-staged pins = total - staged.

func (*Store) Remove

func (s *Store) Remove(iid ffs.APIID, c cid.Cid) error

Remove unpins c for iid regarding any pin type. If c is unpinned for iid, this is a noop.

func (*Store) RemoveStaged

func (s *Store) RemoveStaged(c cid.Cid) error

RemoveStaged deletes from the pinstore c if all existing pins are stage-pins, if not it fails. This is a safe method used by GCs to unpin unpinnable cids.

Jump to

Keyboard shortcuts

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