localstorage

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package localstorage provides methods for saving data on current machine.

Index

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.

Jump to

Keyboard shortcuts

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