Documentation ¶
Overview ¶
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 ¶
- Variables
- type BatchCore
- func (bb *BatchCore) Commit() (err error)
- func (bb *BatchCore) Delete(key []byte, opt *leveldbOpt.WriteOptions) error
- func (bb *BatchCore) Discard()
- func (bb *BatchCore) Dump() []byte
- func (bb *BatchCore) Get(key []byte, opt *leveldbOpt.ReadOptions) (b []byte, err error)
- func (bb *BatchCore) Has(key []byte, opt *leveldbOpt.ReadOptions) (bool, error)
- func (bb *BatchCore) NewIterator(r *leveldbUtil.Range, opt *leveldbOpt.ReadOptions) leveldbIterator.Iterator
- func (bb *BatchCore) Put(key []byte, v []byte, opt *leveldbOpt.WriteOptions) error
- func (bb *BatchCore) Write(batch *leveldb.Batch, opt *leveldbOpt.WriteOptions) (err error)
- type Committable
- type Config
- type DefaultListOptions
- func (o DefaultListOptions) Cursor() []byte
- func (o DefaultListOptions) Encode() string
- func (o DefaultListOptions) Limit() uint64
- func (o DefaultListOptions) Reverse() bool
- func (o *DefaultListOptions) SetCursor(c []byte) ListOptions
- func (o *DefaultListOptions) SetLimit(l uint64) ListOptions
- func (o *DefaultListOptions) SetReverse(r bool) ListOptions
- func (o DefaultListOptions) Template() string
- func (o DefaultListOptions) URLValues() url.Values
- type Item
- type IterItem
- type LevelDBBackend
- func (st *LevelDBBackend) Close() error
- func (st *LevelDBBackend) Commit() error
- func (st *LevelDBBackend) Discard() error
- func (st *LevelDBBackend) Get(k string, i interface{}) (err error)
- func (st *LevelDBBackend) GetIterator(prefix string, option ListOptions) (func() (IterItem, bool), func())
- func (st *LevelDBBackend) GetRaw(k string) (b []byte, err error)
- func (st *LevelDBBackend) Has(k string) (bool, error)
- func (st *LevelDBBackend) Init(config *Config) (err error)
- func (st *LevelDBBackend) New(k string, v interface{}) error
- func (st *LevelDBBackend) News(vs ...Item) (err error)
- func (st *LevelDBBackend) OpenBatch() (*LevelDBBackend, error)
- func (st *LevelDBBackend) OpenSnapshot() (*LevelDBBackend, error)
- func (st *LevelDBBackend) OpenTransaction() (*LevelDBBackend, error)
- func (st *LevelDBBackend) Release() error
- func (st *LevelDBBackend) Remove(k string) error
- func (st *LevelDBBackend) Set(k string, v interface{}) (err error)
- func (st *LevelDBBackend) Sets(vs ...Item) (err error)
- func (st *LevelDBBackend) Walk(prefix string, option *WalkOption, walkFunc WalkFunc) error
- type LevelDBCore
- type ListOptions
- type Model
- type Snapshot
- type StateDB
- func (s *StateDB) Commit() error
- func (s *StateDB) Discard() error
- func (s *StateDB) Get(k string, i interface{}) error
- func (s *StateDB) GetIterator(prefix string, reverse bool) (func() (IterItem, bool), func())
- func (s *StateDB) Has(k string) (bool, error)
- func (s *StateDB) MakeHash() ([]byte, error)
- func (s *StateDB) MakeHashString() (string, error)
- func (s *StateDB) New(k string, i interface{}) error
- func (s *StateDB) News(vs ...Item) error
- func (s *StateDB) Remove(k string) error
- func (s *StateDB) Set(k string, i interface{}) error
- func (s *StateDB) Sets(vs ...Item) error
- type WalkFunc
- type WalkOption
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultMaxLimitListOptions uint64 = 100
View Source
var SupportedStorageType []string = []string{
"memory",
"file",
}
Functions ¶
This section is empty.
Types ¶
type BatchCore ¶
func NewBatchCore ¶
func NewBatchCore(core LevelDBCore) *BatchCore
func (*BatchCore) Delete ¶
func (bb *BatchCore) Delete(key []byte, opt *leveldbOpt.WriteOptions) error
func (*BatchCore) Get ¶
func (bb *BatchCore) Get(key []byte, opt *leveldbOpt.ReadOptions) (b []byte, err error)
func (*BatchCore) Has ¶
func (bb *BatchCore) Has(key []byte, opt *leveldbOpt.ReadOptions) (bool, error)
func (*BatchCore) NewIterator ¶
func (bb *BatchCore) NewIterator(r *leveldbUtil.Range, opt *leveldbOpt.ReadOptions) leveldbIterator.Iterator
NewIterator does not work with `BatchBackend`
func (*BatchCore) Put ¶
func (bb *BatchCore) Put(key []byte, v []byte, opt *leveldbOpt.WriteOptions) error
func (*BatchCore) Write ¶
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 ¶
type Committable interface { Discard() Commit() error }
type Config ¶
func NewConfigFromString ¶
func NewConfigFromURL ¶
func ParseConfig ¶
func (*Config) UnmarshalJSON ¶
type DefaultListOptions ¶
type DefaultListOptions struct {
// contains filtered or unexported fields
}
func NewDefaultListOptions ¶
func NewDefaultListOptions(reverse bool, cursor []byte, limit uint64) *DefaultListOptions
func (DefaultListOptions) Cursor ¶
func (o DefaultListOptions) Cursor() []byte
func (DefaultListOptions) Encode ¶
func (o DefaultListOptions) Encode() string
func (DefaultListOptions) Limit ¶
func (o DefaultListOptions) Limit() uint64
func (DefaultListOptions) Reverse ¶
func (o DefaultListOptions) Reverse() bool
func (*DefaultListOptions) SetCursor ¶
func (o *DefaultListOptions) SetCursor(c []byte) ListOptions
func (*DefaultListOptions) SetLimit ¶
func (o *DefaultListOptions) SetLimit(l uint64) ListOptions
func (*DefaultListOptions) SetReverse ¶
func (o *DefaultListOptions) SetReverse(r bool) ListOptions
func (DefaultListOptions) Template ¶
func (o DefaultListOptions) Template() string
func (DefaultListOptions) URLValues ¶
func (o DefaultListOptions) URLValues() url.Values
type LevelDBBackend ¶
type LevelDBBackend struct { DB *leveldb.DB Core LevelDBCore }
func NewStorage ¶
func NewStorage(config *Config) (st *LevelDBBackend, err error)
func (*LevelDBBackend) Close ¶
func (st *LevelDBBackend) Close() error
func (*LevelDBBackend) Commit ¶
func (st *LevelDBBackend) Commit() error
func (*LevelDBBackend) Discard ¶
func (st *LevelDBBackend) Discard() error
func (*LevelDBBackend) Get ¶
func (st *LevelDBBackend) Get(k string, i interface{}) (err error)
func (*LevelDBBackend) GetIterator ¶
func (st *LevelDBBackend) GetIterator(prefix string, option ListOptions) (func() (IterItem, bool), func())
func (*LevelDBBackend) Init ¶
func (st *LevelDBBackend) Init(config *Config) (err error)
func (*LevelDBBackend) New ¶
func (st *LevelDBBackend) New(k string, v interface{}) error
func (*LevelDBBackend) News ¶
func (st *LevelDBBackend) News(vs ...Item) (err error)
func (*LevelDBBackend) OpenBatch ¶
func (st *LevelDBBackend) OpenBatch() (*LevelDBBackend, error)
func (*LevelDBBackend) OpenSnapshot ¶
func (st *LevelDBBackend) OpenSnapshot() (*LevelDBBackend, error)
func (*LevelDBBackend) OpenTransaction ¶
func (st *LevelDBBackend) OpenTransaction() (*LevelDBBackend, error)
func (*LevelDBBackend) Release ¶
func (st *LevelDBBackend) Release() error
func (*LevelDBBackend) Remove ¶
func (st *LevelDBBackend) Remove(k string) error
func (*LevelDBBackend) Set ¶
func (st *LevelDBBackend) Set(k string, v interface{}) (err error)
func (*LevelDBBackend) Sets ¶
func (st *LevelDBBackend) Sets(vs ...Item) (err error)
func (*LevelDBBackend) Walk ¶
func (st *LevelDBBackend) Walk(prefix string, option *WalkOption, walkFunc WalkFunc) error
type LevelDBCore ¶
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 ¶
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 Snapshot ¶
func NewSnapshot ¶
func NewSnapshot(st *LevelDBBackend) (*Snapshot, error)
func (*Snapshot) Delete ¶
func (s *Snapshot) Delete([]byte, *leveldbOpt.WriteOptions) error
func (*Snapshot) Put ¶
func (s *Snapshot) Put([]byte, []byte, *leveldbOpt.WriteOptions) error
func (*Snapshot) Write ¶
func (s *Snapshot) Write(*leveldb.Batch, *leveldbOpt.WriteOptions) error
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func NewStateDB ¶
func NewStateDB(st *LevelDBBackend) *StateDB
func (*StateDB) GetIterator ¶
func (*StateDB) MakeHashString ¶
type WalkOption ¶
func NewWalkOption ¶
func NewWalkOption(cursor string, limit uint64, reverse bool) *WalkOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.