Documentation ¶
Overview ¶
* Copyright (C) 2019 The onyxchain Authors * This file is part of The onyxchain library. * * The onyxchain is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The onyxchain is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The onyxchain. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2019 The onyxchain Authors * This file is part of The onyxchain library. * * The onyxchain is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The onyxchain is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The onyxchain. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- type JoinIter
- type KeyOrigin
- type MemDB
- func (p *MemDB) Capacity() int
- func (p *MemDB) Delete(key []byte)
- func (db *MemDB) DumpToDot() string
- func (p *MemDB) Find(key []byte) (rkey, value []byte, err error)
- func (p *MemDB) ForEach(f func(key, val []byte))
- func (p *MemDB) Free() int
- func (p *MemDB) Get(key []byte) (value []byte, unkown bool)
- func (p *MemDB) Len() int
- func (p *MemDB) NewIterator(slice *util.Range) iterator.Iterator
- func (p *MemDB) Put(key []byte, value []byte)
- func (p *MemDB) Reset()
- func (p *MemDB) Size() int
- type OverlayDB
- func (self *OverlayDB) ChangeHash() comm.Uint256
- func (self *OverlayDB) CommitTo()
- func (self *OverlayDB) Delete(key []byte)
- func (self *OverlayDB) Error() error
- func (self *OverlayDB) Get(key []byte) (value []byte, err error)
- func (self *OverlayDB) NewIterator(key []byte) common.StoreIterator
- func (self *OverlayDB) Put(key []byte, value []byte)
- func (self *OverlayDB) Reset()
- func (self *OverlayDB) SetError(err error)
Constants ¶
const ( FromMem KeyOrigin = iota FromBack = iota FromBoth = iota )
Variables ¶
var ( ErrNotFound = errors.ErrNotFound ErrIterReleased = errors.New("leveldb/memdb: iterator released") )
Common errors.
Functions ¶
This section is empty.
Types ¶
type JoinIter ¶
type JoinIter struct {
// contains filtered or unexported fields
}
func NewJoinIter ¶
func NewJoinIter(memIter, backendIter common.StoreIterator) *JoinIter
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
MemDB is an in-memdb key/value database.
func NewMemDB ¶
NewMemDB creates a new initialized in-memdb key/value MemDB. The capacity is the initial key/value buffer capacity. The capacity is advisory, not enforced.
This MemDB is append-only, deleting an entry would remove entry node but not reclaim KV buffer.
The returned MemDB instance is safe for concurrent use.
func (*MemDB) Delete ¶
Delete deletes the value for the given key.
It is safe to modify the contents of the arguments after Delete returns.
func (*MemDB) Find ¶
Find finds key/value pair whose key is greater than or equal to the given key. It returns ErrNotFound if the table doesn't contain such pair.
The caller should not modify the contents of the returned slice, but it is safe to modify the contents of the argument after Find returns.
func (*MemDB) Get ¶
Get gets the value for the given key. It returns unkown == true if the MemDB does not contain the key. It returns nil, false if MemDB has deleted the key
The caller should not modify the contents of the returned slice, but it is safe to modify the contents of the argument after Get returns.
func (*MemDB) NewIterator ¶
NewIterator returns an iterator of the MemDB. The returned iterator is not safe for concurrent use, but it is safe to use multiple iterators concurrently, with each in a dedicated goroutine. It is also safe to use an iterator concurrently with modifying its underlying MemDB. However, the resultant key/value pairs are not guaranteed to be a consistent snapshot of the MemDB at a particular point in time.
Slice allows slicing the iterator to only contains keys in the given range. A nil Range.Start is treated as a key before all keys in the MemDB. And a nil Range.Limit is treated as a key after all keys in the MemDB.
The iterator must be released after use, by calling Release method.
Also read Iterator documentation of the leveldb/iterator package.
func (*MemDB) Put ¶
Put sets the value for the given key. It overwrites any previous value for that key; a MemDB is not a multi-map.
It is safe to modify the contents of the arguments after Put returns.
type OverlayDB ¶
type OverlayDB struct {
// contains filtered or unexported fields
}
func NewOverlayDB ¶
func NewOverlayDB(store common.PersistStore) *OverlayDB
func (*OverlayDB) ChangeHash ¶
func (*OverlayDB) NewIterator ¶
func (self *OverlayDB) NewIterator(key []byte) common.StoreIterator
param key is referenced by iterator