Documentation ¶
Index ¶
- Constants
- func NewPersistentSlabStorage(baseStorage atree.BaseStorage) (*atree.PersistentSlabStorage, error)
- type ByteStringValue
- func (v ByteStringValue) ByteSize() uint32
- func (v ByteStringValue) Bytes() []byte
- func (v ByteStringValue) ChildStorables() []atree.Storable
- func (v ByteStringValue) Encode(enc *atree.Encoder) error
- func (v ByteStringValue) Storable(storage atree.SlabStorage, address atree.Address, maxInlineSize uint64) (atree.Storable, error)
- func (v ByteStringValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)
- func (v ByteStringValue) String() string
- type Database
- func (db *Database) ApplyBatch(b *batch) error
- func (db *Database) BytesRetrieved() int
- func (db *Database) BytesStored() int
- func (db *Database) Close() error
- func (db *Database) Commit(root gethCommon.Hash) error
- func (db *Database) Compact(start []byte, limit []byte) error
- func (db *Database) Delete(key []byte) error
- func (db *Database) DropCache()
- func (db *Database) Get(key []byte) ([]byte, error)
- func (db *Database) GetRootHash() (gethCommon.Hash, error)
- func (db *Database) Has(key []byte) (bool, error)
- func (db *Database) Len() int
- func (db *Database) NewBatch() gethDB.Batch
- func (db *Database) NewBatchWithSize(size int) gethDB.Batch
- func (db *Database) NewIterator(prefix []byte, start []byte) gethDB.Iterator
- func (db *Database) NewSnapshot() (gethDB.Snapshot, error)
- func (db *Database) Put(key []byte, value []byte) error
- func (db *Database) ResetReporter()
- func (db *Database) Stat(property string) (string, error)
- type MeteredDatabase
Constants ¶
const ( FlowEVMRootSlabKey = "RootSlabKey" FlowEVMRootHashKey = "RootHash" StorageIDSize = 16 )
Variables ¶
This section is empty.
Functions ¶
func NewPersistentSlabStorage ¶
func NewPersistentSlabStorage(baseStorage atree.BaseStorage) (*atree.PersistentSlabStorage, error)
Types ¶
type ByteStringValue ¶
type ByteStringValue struct {
// contains filtered or unexported fields
}
func NewByteStringValue ¶
func NewByteStringValue(data []byte) ByteStringValue
func (ByteStringValue) ByteSize ¶
func (v ByteStringValue) ByteSize() uint32
func (ByteStringValue) Bytes ¶
func (v ByteStringValue) Bytes() []byte
func (ByteStringValue) ChildStorables ¶
func (v ByteStringValue) ChildStorables() []atree.Storable
func (ByteStringValue) Storable ¶
func (v ByteStringValue) Storable(storage atree.SlabStorage, address atree.Address, maxInlineSize uint64) (atree.Storable, error)
func (ByteStringValue) StoredValue ¶
func (v ByteStringValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)
func (ByteStringValue) String ¶
func (v ByteStringValue) String() string
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is where EVM data is stored.
under the hood, databases uses an Atree map stored under account `flowEVMRootAddress` each key value pairs inserted into this map is of type of ByteStringValue; we use this type instead of atree array, given the EVM environment is not smart enough to interact with a portion of the value and would load everything under a key before opearting on it. This means it could lead to having large slabs for a single value.
func NewDatabase ¶
NewDatabase returns a wrapped map that implements all the required database interface methods.
func (*Database) ApplyBatch ¶
ApplyBatch applys changes from a batch into the database
func (*Database) BytesRetrieved ¶
func (*Database) BytesStored ¶
func (*Database) Commit ¶
func (db *Database) Commit(root gethCommon.Hash) error
Commits the changes from atree into the underlying storage
this method can be merged as part of batcher
func (*Database) Compact ¶
Compact is not supported on a memory database, but there's no need either as a memory database doesn't waste space anyway. Compact is a no op
func (*Database) DropCache ¶
func (db *Database) DropCache()
DropCache drops the database read cache
func (*Database) GetRootHash ¶
func (db *Database) GetRootHash() (gethCommon.Hash, error)
GetRootHash returns the active root hash
func (*Database) Len ¶
Len returns the number of entries currently present in the memory database.
Note, this method is only used for testing (i.e. not public in general) and does not have explicit checks for closed-ness to allow simpler testing code.
func (*Database) NewBatch ¶
NewBatch creates a write-only key-value store that buffers changes to its host database until a final write is called.
func (*Database) NewBatchWithSize ¶
NewBatchWithSize creates a write-only database batch with pre-allocated buffer.
func (*Database) NewIterator ¶
NewIterator is not supported in this database if needed in the future we could implement it using atree iterators
func (*Database) NewSnapshot ¶
NewSnapshot is not supported
func (*Database) ResetReporter ¶
func (db *Database) ResetReporter()
type MeteredDatabase ¶
type MeteredDatabase struct {
*Database
}
MeteredDatabase wrapper around the database purposely built for testing and benchmarking.
func NewMeteredDatabase ¶
func NewMeteredDatabase(led atree.Ledger, flowEVMRootAddress flow.Address) (*MeteredDatabase, error)
NewMeteredDatabase create a database wrapper purposely built for testing and benchmarking.
func (*MeteredDatabase) BytesRead ¶
func (m *MeteredDatabase) BytesRead() int
func (*MeteredDatabase) BytesWritten ¶
func (m *MeteredDatabase) BytesWritten() int
func (*MeteredDatabase) DropCache ¶
func (m *MeteredDatabase) DropCache()
func (*MeteredDatabase) ResetReporter ¶
func (m *MeteredDatabase) ResetReporter()