mapstate

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mapstate implements the State interface for IPFS Cluster by using a map to keep track of the consensus-shared state.

Index

Constants

View Source
const Version = 6

Version is the map state Version. States with old versions should perform an upgrade before.

Variables

This section is empty.

Functions

func NewMapState

func NewMapState() state.State

NewMapState initializes the internal map and returns a new MapState object.

Types

type MapState

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

MapState is mostly a MapDatastore to store the pinset.

func (*MapState) Add

func (st *MapState) Add(ctx context.Context, c *api.Pin) error

Add adds a Pin to the internal map.

func (*MapState) Get

func (st *MapState) Get(ctx context.Context, c cid.Cid) (*api.Pin, bool)

Get returns Pin information for a CID. The returned object has its Cid and Allocations fields initialized, regardless of the presence of the provided Cid in the state. To check the presence, use MapState.Has(cid.Cid).

func (*MapState) GetVersion added in v0.3.1

func (st *MapState) GetVersion() int

GetVersion returns the current version of this state object. It is not necessarily up to date

func (*MapState) Has

func (st *MapState) Has(ctx context.Context, c cid.Cid) bool

Has returns true if the Cid belongs to the State.

func (*MapState) List

func (st *MapState) List(ctx context.Context) []*api.Pin

List provides the list of tracked Pins.

func (*MapState) Marshal added in v0.3.1

func (st *MapState) Marshal(w io.Writer) error

Marshal encodes the state to the given writer. This implements go-libp2p-raft.Marshable.

func (*MapState) Migrate added in v0.3.2

func (st *MapState) Migrate(ctx context.Context, r io.Reader) error

Migrate restores a snapshot from the state's internal bytes and if necessary migrates the format to the current version.

func (*MapState) Rm

func (st *MapState) Rm(ctx context.Context, c cid.Cid) error

Rm removes a Cid from the internal map.

func (*MapState) Unmarshal added in v0.3.1

func (st *MapState) Unmarshal(r io.Reader) error

Unmarshal decodes the state from the given reader. This implements go-libp2p-raft.Marshable.

Jump to

Keyboard shortcuts

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