Documentation
¶
Overview ¶
Copyright 2023 The AmazeChain Authors This file is part of the AmazeChain library.
The AmazeChain library 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 AmazeChain library 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 AmazeChain library. If not, see <http://www.gnu.org/licenses/>. Package ethdb defines the interfaces for an Ethereum data store.
Index ¶
- func NewBatch(tx kv.RwTx, quit <-chan struct{}) *mutation
- func NewHashBatch(tx kv.RwTx, quit <-chan struct{}, tmpdir string) *mapmutation
- type MutationItem
- type ObjectDatabase
- func (db *ObjectDatabase) Append(bucket string, key []byte, value []byte) error
- func (db *ObjectDatabase) AppendDup(bucket string, key []byte, value []byte) error
- func (db *ObjectDatabase) Begin(ctx context.Context, flags ethdb.TxFlags) (ethdb.DbWithPendingMutations, error)
- func (db *ObjectDatabase) BucketExists(name string) (bool, error)
- func (db *ObjectDatabase) ClearBuckets(buckets ...string) error
- func (db *ObjectDatabase) Close()
- func (db *ObjectDatabase) Delete(table string, k []byte) error
- func (db *ObjectDatabase) DropBuckets(buckets ...string) error
- func (db *ObjectDatabase) ForAmount(bucket string, fromPrefix []byte, amount uint32, ...) error
- func (db *ObjectDatabase) ForEach(bucket string, fromPrefix []byte, walker func(k, v []byte) error) error
- func (db *ObjectDatabase) ForPrefix(bucket string, prefix []byte, walker func(k, v []byte) error) error
- func (db *ObjectDatabase) Get(bucket string, key []byte) ([]byte, error)
- func (db *ObjectDatabase) GetOne(bucket string, key []byte) ([]byte, error)
- func (db *ObjectDatabase) Has(bucket string, key []byte) (bool, error)
- func (db *ObjectDatabase) IncrementSequence(bucket string, amount uint64) (res uint64, err error)
- func (db *ObjectDatabase) Last(bucket string) ([]byte, []byte, error)
- func (db *ObjectDatabase) Put(table string, k, v []byte) error
- func (db *ObjectDatabase) ReadSequence(bucket string) (res uint64, err error)
- func (db *ObjectDatabase) RwKV() kv.RwDB
- func (db *ObjectDatabase) SetRwKV(kv kv.RwDB)
- type StateReader
- func (dbr *StateReader) GetOne(bucket string, key []byte) ([]byte, error)
- func (r *StateReader) ReadAccountCode(address types.Address, incarnation uint16, codeHash types.Hash) ([]byte, error)
- func (r *StateReader) ReadAccountCodeSize(address types.Address, incarnation uint16, codeHash types.Hash) (int, error)
- func (r *StateReader) ReadAccountData(address types.Address) (*account.StateAccount, error)
- func (r *StateReader) ReadAccountIncarnation(address types.Address) (uint16, error)
- func (r *StateReader) ReadAccountStorage(address types.Address, incarnation uint16, key *types.Hash) ([]byte, error)
- func (dbr *StateReader) SetBlockNumber(blockNr uint64)
- func (dbr *StateReader) SetReadCodeF(readCodeF func(types.Hash) ([]byte, error))
- type TxDb
- func (m *TxDb) Append(bucket string, key []byte, value []byte) error
- func (m *TxDb) AppendDup(bucket string, key []byte, value []byte) error
- func (m *TxDb) BatchSize() int
- func (m *TxDb) Begin(ctx context.Context, flags ethdb.TxFlags) (ethdb.DbWithPendingMutations, error)
- func (m *TxDb) BucketExists(name string) (bool, error)
- func (m *TxDb) ClearBuckets(buckets ...string) error
- func (m *TxDb) Close()
- func (m *TxDb) Commit() error
- func (m *TxDb) Delete(table string, k []byte) error
- func (m *TxDb) DropBuckets(buckets ...string) error
- func (m *TxDb) ForAmount(bucket string, prefix []byte, amount uint32, walker func(k, v []byte) error) error
- func (m *TxDb) ForEach(bucket string, fromPrefix []byte, walker func(k, v []byte) error) error
- func (m *TxDb) ForPrefix(bucket string, prefix []byte, walker func(k, v []byte) error) error
- func (m *TxDb) Get(bucket string, key []byte) ([]byte, error)
- func (m *TxDb) GetOne(bucket string, key []byte) ([]byte, error)
- func (m *TxDb) Has(bucket string, key []byte) (bool, error)
- func (m *TxDb) IncrementSequence(bucket string, amount uint64) (res uint64, err error)
- func (m *TxDb) Last(bucket string) ([]byte, []byte, error)
- func (m *TxDb) Put(table string, k, v []byte) error
- func (m *TxDb) ReadSequence(bucket string) (res uint64, err error)
- func (m *TxDb) Rollback()
- func (m *TxDb) RwKV() kv.RwDB
- func (m *TxDb) Tx() kv.Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBatch ¶
NewBatch - starts in-mem batch
Common pattern:
batch := db.NewBatch() defer batch.Rollback() ... some calculations on `batch` batch.Commit()
func NewHashBatch ¶
NewBatch - starts in-mem batch
Common pattern:
batch := db.NewBatch() defer batch.Rollback() ... some calculations on `batch` batch.Commit()
Types ¶
type MutationItem ¶
type MutationItem struct {
// contains filtered or unexported fields
}
type ObjectDatabase ¶
type ObjectDatabase struct {
// contains filtered or unexported fields
}
ObjectDatabase - is an object-style interface of DB accessing
func NewObjectDatabase ¶
func NewObjectDatabase(kv kv.RwDB) *ObjectDatabase
NewObjectDatabase returns a AbstractDB wrapper. Deprecated
func (*ObjectDatabase) Append ¶
func (db *ObjectDatabase) Append(bucket string, key []byte, value []byte) error
Append appends a single entry to the end of the bucket.
func (*ObjectDatabase) AppendDup ¶
func (db *ObjectDatabase) AppendDup(bucket string, key []byte, value []byte) error
AppendDup appends a single entry to the end of the bucket.
func (*ObjectDatabase) Begin ¶
func (db *ObjectDatabase) Begin(ctx context.Context, flags ethdb.TxFlags) (ethdb.DbWithPendingMutations, error)
func (*ObjectDatabase) BucketExists ¶
func (db *ObjectDatabase) BucketExists(name string) (bool, error)
func (*ObjectDatabase) ClearBuckets ¶
func (db *ObjectDatabase) ClearBuckets(buckets ...string) error
func (*ObjectDatabase) Close ¶
func (db *ObjectDatabase) Close()
func (*ObjectDatabase) Delete ¶
func (db *ObjectDatabase) Delete(table string, k []byte) error
Delete deletes the key from the queue and database
func (*ObjectDatabase) DropBuckets ¶
func (db *ObjectDatabase) DropBuckets(buckets ...string) error
func (*ObjectDatabase) Get ¶
func (db *ObjectDatabase) Get(bucket string, key []byte) ([]byte, error)
func (*ObjectDatabase) GetOne ¶
func (db *ObjectDatabase) GetOne(bucket string, key []byte) ([]byte, error)
Get returns the value for a given key if it's present.
func (*ObjectDatabase) IncrementSequence ¶
func (db *ObjectDatabase) IncrementSequence(bucket string, amount uint64) (res uint64, err error)
func (*ObjectDatabase) Put ¶
func (db *ObjectDatabase) Put(table string, k, v []byte) error
Put inserts or updates a single entry.
func (*ObjectDatabase) ReadSequence ¶
func (db *ObjectDatabase) ReadSequence(bucket string) (res uint64, err error)
func (*ObjectDatabase) RwKV ¶
func (db *ObjectDatabase) RwKV() kv.RwDB
func (*ObjectDatabase) SetRwKV ¶
func (db *ObjectDatabase) SetRwKV(kv kv.RwDB)
type StateReader ¶
type StateReader struct {
// contains filtered or unexported fields
}
func NewStateReader ¶
func (*StateReader) GetOne ¶
func (dbr *StateReader) GetOne(bucket string, key []byte) ([]byte, error)
func (*StateReader) ReadAccountCode ¶
func (*StateReader) ReadAccountCodeSize ¶
func (*StateReader) ReadAccountData ¶
func (r *StateReader) ReadAccountData(address types.Address) (*account.StateAccount, error)
func (*StateReader) ReadAccountIncarnation ¶
func (r *StateReader) ReadAccountIncarnation(address types.Address) (uint16, error)
func (*StateReader) ReadAccountStorage ¶
func (*StateReader) SetBlockNumber ¶
func (dbr *StateReader) SetBlockNumber(blockNr uint64)
func (*StateReader) SetReadCodeF ¶
func (dbr *StateReader) SetReadCodeF(readCodeF func(types.Hash) ([]byte, error))
type TxDb ¶
type TxDb struct {
// contains filtered or unexported fields
}
TxDb - provides Database interface around ethdb.Tx It's not thread-safe! TxDb not usable after .Commit()/.Rollback() call, but usable after .CommitAndBegin() call you can put unlimited amount of data into this class Walk and MultiWalk methods - work outside of Tx object yet, will implement it later Deprecated nolint