store

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: MPL-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStoreValueUnsetError

func IsStoreValueUnsetError(err error) bool

IsStoreValueUnsetError returns true if an error is of type storeValueUnset

Types

type Iterator

type Iterator interface {
	// Returns the next element of the iterator
	GetNext() (string, error)
	// HasNext returns true if there is at least one more item after the current position
	HasNext() bool
}

Iterator is an iterator for the store

type StdIterator

type StdIterator struct {
	// contains filtered or unexported fields
}

StdIterator is the standard Iterator implementation

func (*StdIterator) GetNext

func (i *StdIterator) GetNext() (string, error)

Next implements the Iterator interface

func (*StdIterator) HasNext

func (i *StdIterator) HasNext() bool

HasNext implements the Iterator interface

type StdStore

type StdStore struct {
	// contains filtered or unexported fields
}

StdStore is the standard implementation of the Store interface

func NewStdStore

func NewStdStore(sealer seal.Sealer) *StdStore

NewStdStore creates and initialises a new StdStore object

func (*StdStore) BeginTransaction

func (s *StdStore) BeginTransaction() (Transaction, error)

BeginTransaction starts a new transaction

func (*StdStore) Get

func (s *StdStore) Get(request string) ([]byte, error)

Get retrieves a value from StdStore by Type and Name

func (*StdStore) Iterator

func (s *StdStore) Iterator(prefix string) (Iterator, error)

Iterator returns an iterator for keys saved in StdStore with a given prefix For an empty prefix this is an iterator for all keys in StdStore

func (*StdStore) LoadState

func (s *StdStore) LoadState() ([]byte, error)

LoadState loads sealed data into StdStore's data

func (*StdStore) Put

func (s *StdStore) Put(request string, requestData []byte) error

Put saves a value in StdStore by Type and Name

func (*StdStore) SetRecoveryData

func (s *StdStore) SetRecoveryData(recoveryData []byte)

SetRecoveryData sets the recovery data that is added to the sealed data.

type Store

type Store interface {
	// BeginTransaction starts a new transaction
	BeginTransaction() (Transaction, error)
	// Get returns a value from store by key
	Get(string) ([]byte, error)
	// Put saves a value to store by key
	Put(string, []byte) error
	// Iterator returns an Iterator for a given prefix
	Iterator(string) (Iterator, error)
}

Store is the interface for persistence

type Transaction

type Transaction interface {
	// Get returns a value from store by key
	Get(string) ([]byte, error)
	// Put saves a value to store by key
	Put(string, []byte) error
	// Iterator returns an Iterator for a given prefix
	Iterator(string) (Iterator, error)
	// Commit ends a transaction and persists the changes
	Commit() error
	// Rollback aborts a transaction. Noop if already committed.
	Rollback()
}

Transaction is a Store transaction.

Jump to

Keyboard shortcuts

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