Documentation ¶
Overview ¶
Package localstorage provides methods for saving data on current machine.
Index ¶
- Variables
- type LocalStorage
- func (s *LocalStorage) Get(ctx context.Context, pulse core.PulseNumber, key []byte) ([]byte, error)
- func (s *LocalStorage) Iterate(ctx context.Context, pulse core.PulseNumber, prefix []byte, ...) error
- func (s *LocalStorage) Set(ctx context.Context, pulse core.PulseNumber, key []byte, data []byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotFound = errors.New("record not found")
)
Functions ¶
This section is empty.
Types ¶
type LocalStorage ¶
type LocalStorage struct {
// contains filtered or unexported fields
}
LocalStorage allows node to save local data.
func NewLocalStorage ¶
func NewLocalStorage(db storage.DBContext) *LocalStorage
NewLocalStorage create new storage instance.
func (*LocalStorage) Get ¶
func (s *LocalStorage) Get(ctx context.Context, pulse core.PulseNumber, key []byte) ([]byte, error)
Get retrieves data from storage.
func (*LocalStorage) Iterate ¶
func (s *LocalStorage) Iterate( ctx context.Context, pulse core.PulseNumber, prefix []byte, handler func(k, v []byte) error, ) error
Iterate iterates over all record with specified prefix and calls handler with key and value of that record.
The key will be returned without prefix (e.g. the remaining slice) and value will be returned as it was saved.
func (*LocalStorage) Set ¶
func (s *LocalStorage) Set(ctx context.Context, pulse core.PulseNumber, key []byte, data []byte) error
Set saves data in storage.
Click to show internal directories.
Click to hide internal directories.