dao

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyExists is returned when transaction exists in dao.
	ErrAlreadyExists = errors.New("transaction already exists")
	// ErrHasConflicts is returned when transaction is in the list of conflicting
	// transactions which are already in dao.
	ErrHasConflicts = errors.New("transaction has conflicts")
)

HasTransaction errors.

Functions

This section is empty.

Types

type Simple

type Simple struct {
	Version Version
	Store   *storage.MemCachedStore
	// contains filtered or unexported fields
}

Simple is memCached wrapper around DB, simple DAO implementation.

func NewSimple

func NewSimple(backend storage.Store) *Simple

NewSimple creates new simple dao using provided backend store.

func (*Simple) DeleteBlock

func (dao *Simple) DeleteBlock(h common.Hash) error

DeleteBlock removes block from dao. It's not atomic, so make sure you're using private MemCached instance here.

func (*Simple) DeleteStorageItem

func (dao *Simple) DeleteStorageItem(hash common.Address, key []byte)

DeleteStorageItem drops storage item for the given id with the given key from the store.

func (*Simple) GetAndDecode

func (dao *Simple) GetAndDecode(entity io.Serializable, key []byte) error

GetAndDecode performs get operation and decoding with serializable structures.

func (*Simple) GetBatch

func (dao *Simple) GetBatch() *storage.MemBatch

GetBatch returns currently accumulated DB changeset.

func (*Simple) GetBlock

func (dao *Simple) GetBlock(hash common.Hash) (*block.Block, *types.Receipt, error)

GetBlock returns Block by the given hash if it exists in the store.

func (*Simple) GetCurrentBlockHeight

func (dao *Simple) GetCurrentBlockHeight() (uint32, error)

GetCurrentBlockHeight returns the current block height found in the underlying store.

func (*Simple) GetCurrentHeaderHeight

func (dao *Simple) GetCurrentHeaderHeight() (i uint32, h common.Hash, err error)

GetCurrentHeaderHeight returns the current header height and hash from the underlying store.

func (*Simple) GetHeader

func (dao *Simple) GetHeader(hash common.Hash) (*block.Header, error)

func (*Simple) GetHeaderHashes

func (dao *Simple) GetHeaderHashes() ([]common.Hash, error)

GetHeaderHashes returns a sorted list of header hashes retrieved from the given underlying store.

func (*Simple) GetPrivate

func (dao *Simple) GetPrivate() *Simple

GetPrivate returns new DAO instance with another layer of private MemCachedStore around the current DAO Store.

func (*Simple) GetReceipt

func (dao *Simple) GetReceipt(hash common.Hash) (*types.Receipt, error)

GetAppExecResults gets application execution results with the specified trigger from the given store.

func (*Simple) GetStateSyncPoint

func (dao *Simple) GetStateSyncPoint() (uint32, error)

GetStateSyncPoint returns current state synchronisation point P.

func (*Simple) GetStorageItem

func (dao *Simple) GetStorageItem(address common.Address, key []byte) state.StorageItem

GetStorageItem returns StorageItem if it exists in the given store.

func (*Simple) GetStorageItems

func (dao *Simple) GetStorageItems(hash common.Address) ([]state.StorageItemWithKey, error)

GetStorageItems returns all storage items for a given id.

func (*Simple) GetStorageItemsWithPrefix

func (dao *Simple) GetStorageItemsWithPrefix(hash common.Address, prefix []byte) ([]state.StorageItemWithKey, error)

GetStorageItemsWithPrefix returns all storage items with given id for a given scripthash.

func (*Simple) GetTransaction

func (dao *Simple) GetTransaction(hash common.Hash) (*transaction.Transaction, *types.Receipt, error)

GetTransaction returns Transaction and its height by the given hash if it exists in the store. It does not return dummy transactions.

func (*Simple) GetVersion

func (dao *Simple) GetVersion() (Version, error)

GetVersion attempts to get the current version stored in the underlying store.

func (*Simple) GetWrapped

func (dao *Simple) GetWrapped() *Simple

GetWrapped returns new DAO instance with another layer of wrapped MemCachedStore around the current DAO Store.

func (*Simple) HasTransaction

func (dao *Simple) HasTransaction(hash common.Hash) error

HasTransaction returns nil if the given store does not contain the given Transaction hash. It returns an error in case if transaction is in chain or in the list of conflicting transactions.

func (*Simple) Persist

func (dao *Simple) Persist() (int, error)

Persist flushes all the changes made into the (supposedly) persistent underlying store. It doesn't block accesses to DAO from other threads.

func (*Simple) PersistSync

func (dao *Simple) PersistSync() (int, error)

PersistSync flushes all the changes made into the (supposedly) persistent underlying store. It's a synchronous version of Persist that doesn't allow other threads to work with DAO while flushing the Store.

func (*Simple) PutCurrentHeader

func (dao *Simple) PutCurrentHeader(h common.Hash, index uint32)

PutCurrentHeader stores current header.

func (*Simple) PutStorageItem

func (dao *Simple) PutStorageItem(hash common.Address, key []byte, si state.StorageItem)

PutStorageItem puts given StorageItem for given id with given key into the given store.

func (*Simple) PutVersion

func (dao *Simple) PutVersion(v Version)

PutVersion stores the given version in the underlying store.

func (*Simple) Seek

func (dao *Simple) Seek(hash common.Address, rng storage.SeekRange, f func(k, v []byte) bool)

Seek executes f for all storage items matching a given `rng` (matching given prefix and starting from the point specified). If key or value is to be used outside of f, they may not be copied. Seek continues iterating until false is returned from f.

func (*Simple) SeekAsync

func (dao *Simple) SeekAsync(ctx context.Context, hash common.Address, rng storage.SeekRange) chan storage.KeyValue

SeekAsync sends all storage items matching a given `rng` (matching given prefix and starting from the point specified) to a channel and returns the channel. Resulting keys and values may not be copied.

func (*Simple) StoreAsBlock

func (dao *Simple) StoreAsBlock(block *block.Block, receipt *types.Receipt) error

func (*Simple) StoreAsCurrentBlock

func (dao *Simple) StoreAsCurrentBlock(block *block.Block)

StoreAsCurrentBlock stores a hash of the given block with prefix SYSCurrentBlock. It can reuse given buffer for the purpose of value serialization.

func (*Simple) StoreAsHeader

func (dao *Simple) StoreAsHeader(header *block.Header) error

func (*Simple) StoreAsTransaction

func (dao *Simple) StoreAsTransaction(tx *transaction.Transaction, aer *types.Receipt) error

func (*Simple) StoreHeaderHashes

func (dao *Simple) StoreHeaderHashes(hashes []common.Hash, height uint32) error

StoreHeaderHashes pushes a batch of header hashes into the store.

type Version

type Version struct {
	StoragePrefix       storage.KeyPrefix
	KeepOnlyLatestState bool
	Value               string
}

Version represents current dao version.

func (*Version) Bytes

func (v *Version) Bytes() []byte

Bytes encodes v to a byte-slice.

func (*Version) FromBytes

func (v *Version) FromBytes(data []byte) error

FromBytes decodes v from a byte-slice.

Jump to

Keyboard shortcuts

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