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
- func NewMapState() state.State
- type MapState
- func (st *MapState) Add(ctx context.Context, c *api.Pin) error
- func (st *MapState) Get(ctx context.Context, c cid.Cid) (*api.Pin, bool)
- func (st *MapState) GetVersion() int
- func (st *MapState) Has(ctx context.Context, c cid.Cid) bool
- func (st *MapState) List(ctx context.Context) []*api.Pin
- func (st *MapState) Marshal(w io.Writer) error
- func (st *MapState) Migrate(ctx context.Context, r io.Reader) error
- func (st *MapState) Rm(ctx context.Context, c cid.Cid) error
- func (st *MapState) Unmarshal(r io.Reader) error
Constants ¶
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 ¶
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) 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) Marshal ¶ added in v0.3.1
Marshal encodes the state to the given writer. This implements go-libp2p-raft.Marshable.
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.