Documentation ¶
Index ¶
- Constants
- func CommitBatch(db Database, height uint64) error
- type Batch
- type BatchMgr
- type Database
- type LDBDatabase
- func (self *LDBDatabase) Close()
- func (self *LDBDatabase) Delete(key []byte) error
- func (self *LDBDatabase) Destroy() error
- func (self *LDBDatabase) DestroyByRange(start, end []byte) error
- func (self *LDBDatabase) Get(key []byte) ([]byte, error)
- func (self *LDBDatabase) LDB() *leveldb.DB
- func (db *LDBDatabase) NewBatch() Batch
- func (self *LDBDatabase) NewIterator(prefix []byte) iterator.Iterator
- func (self *LDBDatabase) NewIteratorWithPrefix(prefix []byte) iterator.Iterator
- func (self *LDBDatabase) Put(key []byte, value []byte) error
- type TinyDB
- func (tdb *TinyDB) GetBlock(height uint64, hash common.Hash) (*types.Block, error)
- func (tdb *TinyDB) GetHash(height uint64) (common.Hash, error)
- func (tdb *TinyDB) GetHeader(height uint64, hash common.Hash) (*types.Header, error)
- func (tdb *TinyDB) GetHeight(hash common.Hash) (uint64, error)
- func (tdb *TinyDB) GetLastBlock() (common.Hash, error)
- func (tdb *TinyDB) GetLastHeader() (common.Hash, error)
- func (tdb *TinyDB) GetReceipt(txHash common.Hash) (*types.Receipt, error)
- func (tdb *TinyDB) GetTxMeta(txHash common.Hash) (*types.TxMeta, error)
- func (tdb *TinyDB) LDB() Database
- func (tdb *TinyDB) PutBlock(batch Batch, block *types.Block, sync, flush bool) error
- func (tdb *TinyDB) PutHash(batch Batch, height uint64, hash common.Hash, sync, flush bool) error
- func (tdb *TinyDB) PutHeader(batch Batch, header *types.Header, sync, flush bool) error
- func (tdb *TinyDB) PutHeight(batch Batch, hash common.Hash, height uint64, sync, flush bool) error
- func (tdb *TinyDB) PutLastBlock(batch Batch, hash common.Hash, sync, flush bool) error
- func (tdb *TinyDB) PutLastHeader(batch Batch, hash common.Hash, sync, flush bool) error
- func (tdb *TinyDB) PutReceipt(batch Batch, txHash common.Hash, receipt *types.Receipt, sync, flush bool) error
- func (tdb *TinyDB) PutTxMetas(batch Batch, txs types.Transactions, hash common.Hash, height uint64, ...) error
Constants ¶
const ( KeyLastHeader = "LastHeader" KeyLastBlock = "LastBlock" )
Variables ¶
This section is empty.
Functions ¶
func CommitBatch ¶
Types ¶
type Batch ¶
type BatchMgr ¶
type BatchMgr struct {
// contains filtered or unexported fields
}
BatchMgr manages db write batch
type LDBDatabase ¶
type LDBDatabase struct {
// contains filtered or unexported fields
}
the Database for LevelDB LDBDatabase implements the DataBase interface
func NewLDBDataBase ¶
func NewLDBDataBase(filepath string) (*LDBDatabase, error)
NewLDBDataBase new a LDBDatabase instance require a data filepath return *LDBDataBase and will return an error with type of ErrCorrupted if corruption detected in the DB.
func (*LDBDatabase) Delete ¶
func (self *LDBDatabase) Delete(key []byte) error
Delete deletes the value for the given key
func (*LDBDatabase) Destroy ¶
func (self *LDBDatabase) Destroy() error
Destroy, clean the whole database, warning: bad performance if to many data in the db
func (*LDBDatabase) DestroyByRange ¶
func (self *LDBDatabase) DestroyByRange(start, end []byte) error
DestroyByRange, clean data which key in range [start, end)
func (*LDBDatabase) Get ¶
func (self *LDBDatabase) Get(key []byte) ([]byte, error)
Get gets value for the given key, it returns ErrNotFound if the Database does not contains the key
func (*LDBDatabase) LDB ¶
func (self *LDBDatabase) LDB() *leveldb.DB
LDB returns *leveldb.DB instance
func (*LDBDatabase) NewBatch ¶
func (db *LDBDatabase) NewBatch() Batch
NewBatch returns a Batch instance it allows batch-operation
func (*LDBDatabase) NewIterator ¶
func (self *LDBDatabase) NewIterator(prefix []byte) iterator.Iterator
NewIterator returns a Iterator for traversing the database
func (*LDBDatabase) NewIteratorWithPrefix ¶
func (self *LDBDatabase) NewIteratorWithPrefix(prefix []byte) iterator.Iterator
type TinyDB ¶
type TinyDB struct {
// contains filtered or unexported fields
}
TinyDB stores and manages blockchain data