database

package
v0.32.10-master-storeh... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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) Encode

func (v ByteStringValue) Encode(enc *atree.Encoder) error

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

func NewDatabase(led atree.Ledger, flowEVMRootAddress flow.Address) (*Database, error)

NewDatabase returns a wrapped map that implements all the required database interface methods.

func (*Database) ApplyBatch

func (db *Database) ApplyBatch(b *batch) error

ApplyBatch applys changes from a batch into the database

func (*Database) BytesRetrieved

func (db *Database) BytesRetrieved() int

func (*Database) BytesStored

func (db *Database) BytesStored() int

func (*Database) Close

func (db *Database) Close() error

Close is a no-op

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

func (db *Database) Compact(start []byte, limit []byte) error

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) Delete

func (db *Database) Delete(key []byte) error

Delete removes the key from the key-value store.

func (*Database) DropCache

func (db *Database) DropCache()

DropCache drops the database read cache

func (*Database) Get

func (db *Database) Get(key []byte) ([]byte, error)

Get retrieves the given key if it's present in the key-value store.

func (*Database) GetRootHash

func (db *Database) GetRootHash() (gethCommon.Hash, error)

GetRootHash returns the active root hash

func (*Database) Has

func (db *Database) Has(key []byte) (bool, error)

Has checks if a key is present in the key-value store.

func (*Database) Len

func (db *Database) Len() int

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

func (db *Database) NewBatch() gethDB.Batch

NewBatch creates a write-only key-value store that buffers changes to its host database until a final write is called.

func (*Database) NewBatchWithSize

func (db *Database) NewBatchWithSize(size int) gethDB.Batch

NewBatchWithSize creates a write-only database batch with pre-allocated buffer.

func (*Database) NewIterator

func (db *Database) NewIterator(prefix []byte, start []byte) gethDB.Iterator

NewIterator is not supported in this database if needed in the future we could implement it using atree iterators

func (*Database) NewSnapshot

func (db *Database) NewSnapshot() (gethDB.Snapshot, error)

NewSnapshot is not supported

func (*Database) Put

func (db *Database) Put(key []byte, value []byte) error

Put inserts the given value into the key-value store.

func (*Database) ResetReporter

func (db *Database) ResetReporter()

func (*Database) Stat

func (db *Database) Stat(property string) (string, error)

Stat method is not supported

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL