sebak: boscoin.io/sebak/lib/storage Index | Files | Directories

package storage

import "boscoin.io/sebak/lib/storage"

Provides a replacement for LevelDBBackend suitable for unit tests

LevelDB allows one to create a memory DB where we can store test data during our unit tests

Index

Package Files

batch.go leveldb.go options.go snapshot.go statedb.go storage.go test.go

Variables

var DefaultMaxLimitListOptions uint64 = 100
var SupportedStorageType []string = []string{
    "memory",
    "file",
}

type BatchCore Uses

type BatchCore struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewBatchCore Uses

func NewBatchCore(core LevelDBCore) *BatchCore

func (*BatchCore) Commit Uses

func (bb *BatchCore) Commit() (err error)

func (*BatchCore) Delete Uses

func (bb *BatchCore) Delete(key []byte, opt *leveldbOpt.WriteOptions) error

func (*BatchCore) Discard Uses

func (bb *BatchCore) Discard()

func (*BatchCore) Dump Uses

func (bb *BatchCore) Dump() []byte

func (*BatchCore) Get Uses

func (bb *BatchCore) Get(key []byte, opt *leveldbOpt.ReadOptions) (b []byte, err error)

func (*BatchCore) Has Uses

func (bb *BatchCore) Has(key []byte, opt *leveldbOpt.ReadOptions) (bool, error)

func (*BatchCore) NewIterator Uses

func (bb *BatchCore) NewIterator(r *leveldbUtil.Range, opt *leveldbOpt.ReadOptions) leveldbIterator.Iterator

NewIterator does not work with `BatchBackend`

func (*BatchCore) Put Uses

func (bb *BatchCore) Put(key []byte, v []byte, opt *leveldbOpt.WriteOptions) error

func (*BatchCore) Write Uses

func (bb *BatchCore) Write(batch *leveldb.Batch, opt *leveldbOpt.WriteOptions) (err error)

Write will write the existing contents of `BatchBackend.batch` and then argument, batch will be written.

type Committable Uses

type Committable interface {
    Discard()
    Commit() error
}

type Config Uses

type Config url.URL

func NewConfigFromString Uses

func NewConfigFromString(s string) (e *Config, err error)

func NewConfigFromURL Uses

func NewConfigFromURL(u *url.URL) *Config

func ParseConfig Uses

func ParseConfig(s string) (u *Config, err error)

func (*Config) Query Uses

func (e *Config) Query() url.Values

func (*Config) String Uses

func (e *Config) String() string

func (*Config) UnmarshalJSON Uses

func (e *Config) UnmarshalJSON(b []byte) error

type DefaultListOptions Uses

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

func NewDefaultListOptions Uses

func NewDefaultListOptions(reverse bool, cursor []byte, limit uint64) *DefaultListOptions

func (DefaultListOptions) Cursor Uses

func (o DefaultListOptions) Cursor() []byte

func (DefaultListOptions) Encode Uses

func (o DefaultListOptions) Encode() string

func (DefaultListOptions) Limit Uses

func (o DefaultListOptions) Limit() uint64

func (DefaultListOptions) Reverse Uses

func (o DefaultListOptions) Reverse() bool

func (*DefaultListOptions) SetCursor Uses

func (o *DefaultListOptions) SetCursor(c []byte) ListOptions

func (*DefaultListOptions) SetLimit Uses

func (o *DefaultListOptions) SetLimit(l uint64) ListOptions

func (*DefaultListOptions) SetReverse Uses

func (o *DefaultListOptions) SetReverse(r bool) ListOptions

func (DefaultListOptions) Template Uses

func (o DefaultListOptions) Template() string

func (DefaultListOptions) URLValues Uses

func (o DefaultListOptions) URLValues() url.Values

type Item Uses

type Item struct {
    Key   string
    Value interface{}
}

type IterItem Uses

type IterItem struct {
    N     uint64
    Key   []byte
    Value []byte
}

func (IterItem) Clone Uses

func (i IterItem) Clone() IterItem

type LevelDBBackend Uses

type LevelDBBackend struct {
    DB  *leveldb.DB

    Core LevelDBCore
}

func NewStorage Uses

func NewStorage(config *Config) (st *LevelDBBackend, err error)

func NewTestStorage Uses

func NewTestStorage() *LevelDBBackend

Returns:

A new memory DB

func (*LevelDBBackend) Close Uses

func (st *LevelDBBackend) Close() error

func (*LevelDBBackend) Commit Uses

func (st *LevelDBBackend) Commit() error

func (*LevelDBBackend) Discard Uses

func (st *LevelDBBackend) Discard() error

func (*LevelDBBackend) Get Uses

func (st *LevelDBBackend) Get(k string, i interface{}) (err error)

func (*LevelDBBackend) GetIterator Uses

func (st *LevelDBBackend) GetIterator(prefix string, option ListOptions) (func() (IterItem, bool), func())

func (*LevelDBBackend) GetRaw Uses

func (st *LevelDBBackend) GetRaw(k string) (b []byte, err error)

func (*LevelDBBackend) Has Uses

func (st *LevelDBBackend) Has(k string) (bool, error)

func (*LevelDBBackend) Init Uses

func (st *LevelDBBackend) Init(config *Config) (err error)

func (*LevelDBBackend) New Uses

func (st *LevelDBBackend) New(k string, v interface{}) error

func (*LevelDBBackend) News Uses

func (st *LevelDBBackend) News(vs ...Item) (err error)

func (*LevelDBBackend) OpenBatch Uses

func (st *LevelDBBackend) OpenBatch() (*LevelDBBackend, error)

func (*LevelDBBackend) OpenSnapshot Uses

func (st *LevelDBBackend) OpenSnapshot() (*LevelDBBackend, error)

func (*LevelDBBackend) OpenTransaction Uses

func (st *LevelDBBackend) OpenTransaction() (*LevelDBBackend, error)

func (*LevelDBBackend) Release Uses

func (st *LevelDBBackend) Release() error

func (*LevelDBBackend) Remove Uses

func (st *LevelDBBackend) Remove(k string) error

func (*LevelDBBackend) Set Uses

func (st *LevelDBBackend) Set(k string, v interface{}) (err error)

func (*LevelDBBackend) Sets Uses

func (st *LevelDBBackend) Sets(vs ...Item) (err error)

func (*LevelDBBackend) Walk Uses

func (st *LevelDBBackend) Walk(prefix string, option *WalkOption, walkFunc WalkFunc) error

type LevelDBCore Uses

type LevelDBCore interface {
    Has([]byte, *leveldbOpt.ReadOptions) (bool, error)
    Get([]byte, *leveldbOpt.ReadOptions) ([]byte, error)
    NewIterator(*leveldbUtil.Range, *leveldbOpt.ReadOptions) leveldbIterator.Iterator
    Put([]byte, []byte, *leveldbOpt.WriteOptions) error
    Write(*leveldb.Batch, *leveldbOpt.WriteOptions) error
    Delete([]byte, *leveldbOpt.WriteOptions) error
}

type ListOptions Uses

type ListOptions interface {
    Reverse() bool
    SetReverse(bool) ListOptions
    Cursor() []byte
    SetCursor([]byte) ListOptions
    Limit() uint64
    SetLimit(uint64) ListOptions
    Template() string
    URLValues() url.Values
    Encode() string
}

type Model Uses

type Model struct {
}

type Snapshot Uses

type Snapshot struct {
    *leveldb.Snapshot
}

func NewSnapshot Uses

func NewSnapshot(st *LevelDBBackend) (*Snapshot, error)

func (*Snapshot) Delete Uses

func (s *Snapshot) Delete([]byte, *leveldbOpt.WriteOptions) error

func (*Snapshot) Put Uses

func (s *Snapshot) Put([]byte, []byte, *leveldbOpt.WriteOptions) error

func (*Snapshot) Write Uses

func (s *Snapshot) Write(*leveldb.Batch, *leveldbOpt.WriteOptions) error

type StateDB Uses

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

func NewStateDB Uses

func NewStateDB(st *LevelDBBackend) *StateDB

func (*StateDB) Commit Uses

func (s *StateDB) Commit() error

func (*StateDB) Discard Uses

func (s *StateDB) Discard() error

func (*StateDB) Get Uses

func (s *StateDB) Get(k string, i interface{}) error

func (*StateDB) GetIterator Uses

func (s *StateDB) GetIterator(prefix string, reverse bool) (func() (IterItem, bool), func())

func (*StateDB) Has Uses

func (s *StateDB) Has(k string) (bool, error)

func (*StateDB) MakeHash Uses

func (s *StateDB) MakeHash() ([]byte, error)

func (*StateDB) MakeHashString Uses

func (s *StateDB) MakeHashString() (string, error)

func (*StateDB) New Uses

func (s *StateDB) New(k string, i interface{}) error

func (*StateDB) News Uses

func (s *StateDB) News(vs ...Item) error

func (*StateDB) Remove Uses

func (s *StateDB) Remove(k string) error

func (*StateDB) Set Uses

func (s *StateDB) Set(k string, i interface{}) error

func (*StateDB) Sets Uses

func (s *StateDB) Sets(vs ...Item) error

type WalkFunc Uses

type WalkFunc func(key, value []byte) (bool, error)

type WalkOption Uses

type WalkOption struct {
    Cursor  string
    Limit   uint64
    Reverse bool
}

func NewWalkOption Uses

func NewWalkOption(cursor string, limit uint64, reverse bool) *WalkOption

Directories

PathSynopsis
statedb
statedb/trie

Package storage imports 15 packages (graph) and is imported by 22 packages. Updated 2019-03-13. Refresh now. Tools for package owners.