Documentation
¶
Overview ¶
Package dsstate implements the IPFS Cluster state interface using an underlying go-datastore.
Index ¶
- func DefaultHandle() codec.Handle
- type State
- func (st *State) Add(ctx context.Context, c *api.Pin) error
- func (st *State) Get(ctx context.Context, c cid.Cid) (*api.Pin, bool)
- func (st *State) GetVersion() int
- func (st *State) Has(ctx context.Context, c cid.Cid) bool
- func (st *State) List(ctx context.Context) []*api.Pin
- func (st *State) Marshal(w io.Writer) error
- func (st *State) Migrate(ctx context.Context, r io.Reader) error
- func (st *State) Rm(ctx context.Context, c cid.Cid) error
- func (st *State) SetVersion(v int) error
- func (st *State) Unmarshal(r io.Reader) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHandle ¶
DefaultHandle returns the codec handler of choice (Msgpack).
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
State implements the IPFS Cluster "state" interface by wrapping a go-datastore and choosing how api.Pin objects are stored in it. It also provides serialization methods for the whole state which are datastore-independent.
func New ¶
New returns a new state using the given datastore.
All keys are namespaced with the given string when written. Thus the same go-datastore can be sharded for different uses.
The Handle controls options for the serialization of items and the state itself.
func (*State) Get ¶
Get returns a Pin from the store and whether it was present. When not present, a default pin is returned.
func (*State) GetVersion ¶
GetVersion returns the current state version.
func (*State) List ¶
List returns the unsorted list of all Pins that have been added to the datastore.
func (*State) Marshal ¶
Marshal dumps the state to a writer. It does this by encoding every key/value in the store. The keys are stored without the namespace part to reduce the size of the snapshot.
func (*State) Migrate ¶
Migrate migrates an older state version to the current one. This is a no-op for now.
func (*State) SetVersion ¶
SetVersion allows to manually modify the state version.