mapstate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2017 License: MIT Imports: 7 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 = 2

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

Variables

This section is empty.

Functions

This section is empty.

Types

type MapState

type MapState struct {
	PinMap  map[string]api.PinSerial
	Version int
	// contains filtered or unexported fields
}

MapState is a very simple database to store the state of the system using a Go map. It is thread safe. It implements the State interface.

func NewMapState

func NewMapState() *MapState

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

func (*MapState) Add

func (st *MapState) Add(c api.Pin) error

Add adds a Pin to the internal map.

func (*MapState) Get

func (st *MapState) Get(c *cid.Cid) api.Pin

Get returns Pin information for a CID.

func (*MapState) Has

func (st *MapState) Has(c *cid.Cid) bool

Has returns true if the Cid belongs to the State.

func (*MapState) List

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

List provides the list of tracked Pins.

func (*MapState) Restore added in v0.0.11

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

Restore takes a reader and restores a snapshot. It should migrate the format if it is not compatible with the current version.

func (*MapState) Rm

func (st *MapState) Rm(c *cid.Cid) error

Rm removes a Cid from the internal map.

func (*MapState) Snapshot added in v0.0.11

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

Snapshot dumps the MapState to the given writer, in pretty json format.

Jump to

Keyboard shortcuts

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