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, bool)
- 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) Migrate(r io.Reader) error
- func (st *MapState) Rm(c cid.Cid) error
- func (st *MapState) Unmarshal(bs []byte) error
Constants ¶
const Version = 5
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) Get ¶
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
GetVersion returns the current version of this state object. It is not necessarily up to date
func (*MapState) Migrate ¶ added in v0.3.2
Migrate restores a snapshot from the state's internal bytes and if necessary migrates the format to the current version.
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