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
- type MapState
- func (st *MapState) Add(c api.Pin) error
- func (st *MapState) Get(c *cid.Cid) api.Pin
- func (st *MapState) GetVersion() int
- func (st *MapState) Has(c *cid.Cid) bool
- func (st *MapState) List() []api.Pin
- func (st *MapState) Marshal() ([]byte, error)
- func (st *MapState) Restore(r io.Reader) error
- func (st *MapState) Rm(c *cid.Cid) error
- func (st *MapState) Snapshot(w io.Writer) error
- func (st *MapState) Unmarshal(bs []byte) error
Constants ¶
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) GetVersion ¶ added in v0.3.1
GetVersion returns the current version of this state object. It is not necessarily up to date
func (*MapState) Restore ¶ added in v0.0.11
Restore restores a snapshot from the state's internal bytes. It should migrate the format if it is not compatible with the current version.
func (*MapState) Snapshot ¶ added in v0.0.11
Snapshot dumps the MapState to the given writer, in pretty json format.
func (*MapState) Unmarshal ¶ added in v0.3.1
Unmarshal decodes the state using msgpack. It first decodes just the version number. If this is not the current version the bytes are stored within the state's internal reader, which can be migrated to the current version in a later call to restore. Note: Out of date version is not an error