dao

package
v0.98.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: MIT Imports: 15 Imported by: 1

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 DAO

type DAO interface {
	AppendAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error
	DeleteBlock(h util.Uint256, buf *io.BufBinWriter) error
	DeleteContractID(id int32) error
	DeleteStorageItem(id int32, key []byte) error
	GetAndDecode(entity io.Serializable, key []byte) error
	GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]state.AppExecResult, error)
	GetBatch() *storage.MemBatch
	GetBlock(hash util.Uint256) (*block.Block, error)
	GetContractScriptHash(id int32) (util.Uint160, error)
	GetCurrentBlockHeight() (uint32, error)
	GetCurrentHeaderHeight() (i uint32, h util.Uint256, err error)
	GetHeaderHashes() ([]util.Uint256, error)
	GetTokenTransferInfo(acc util.Uint160) (*state.TokenTransferInfo, error)
	GetTokenTransferLog(acc util.Uint160, index uint32, isNEP11 bool) (*state.TokenTransferLog, error)
	GetStateSyncPoint() (uint32, error)
	GetStateSyncCurrentBlockHeight() (uint32, error)
	GetStorageItem(id int32, key []byte) state.StorageItem
	GetStorageItems(id int32) ([]state.StorageItemWithKey, error)
	GetStorageItemsWithPrefix(id int32, prefix []byte) ([]state.StorageItemWithKey, error)
	GetTransaction(hash util.Uint256) (*transaction.Transaction, uint32, error)
	GetVersion() (Version, error)
	GetWrapped() DAO
	HasTransaction(hash util.Uint256) error
	Persist() (int, error)
	PersistSync() (int, error)
	PutAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error
	PutContractID(id int32, hash util.Uint160) error
	PutCurrentHeader(hashAndIndex []byte) error
	PutTokenTransferInfo(acc util.Uint160, bs *state.TokenTransferInfo) error
	PutTokenTransferLog(acc util.Uint160, index uint32, isNEP11 bool, lg *state.TokenTransferLog) error
	PutStateSyncPoint(p uint32) error
	PutStateSyncCurrentBlockHeight(h uint32) error
	PutStorageItem(id int32, key []byte, si state.StorageItem) error
	PutVersion(v Version) error
	Seek(id int32, prefix []byte, f func(k, v []byte))
	SeekAsync(ctx context.Context, id int32, prefix []byte) chan storage.KeyValue
	StoreAsBlock(block *block.Block, buf *io.BufBinWriter) error
	StoreAsCurrentBlock(block *block.Block, buf *io.BufBinWriter) error
	StoreAsTransaction(tx *transaction.Transaction, index uint32, buf *io.BufBinWriter) error
	// contains filtered or unexported methods
}

DAO is a data access object.

type Simple

type Simple struct {
	Version Version
	Store   *storage.MemCachedStore
}

Simple is memCached wrapper around DB, simple DAO implementation.

func NewSimple

func NewSimple(backend storage.Store, stateRootInHeader bool, p2pSigExtensions bool) *Simple

NewSimple creates new simple dao using provided backend store.

func (*Simple) AppendAppExecResult added in v0.92.0

func (dao *Simple) AppendAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error

AppendAppExecResult appends given application execution result to the existing set of execution results for the corresponding hash. It can reuse given buffer for the purpose of value serialization.

func (*Simple) DeleteBlock added in v0.92.0

func (dao *Simple) DeleteBlock(h util.Uint256, w *io.BufBinWriter) error

DeleteBlock removes block from dao.

func (*Simple) DeleteContractID added in v0.92.0

func (dao *Simple) DeleteContractID(id int32) error

DeleteContractID deletes contract's id to hash mapping.

func (*Simple) DeleteStorageItem

func (dao *Simple) DeleteStorageItem(id int32, key []byte) error

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) GetAppExecResults added in v0.92.0

func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]state.AppExecResult, error)

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

func (*Simple) GetBatch

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

GetBatch returns currently accumulated DB changeset.

func (*Simple) GetBlock

func (dao *Simple) GetBlock(hash util.Uint256) (*block.Block, error)

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

func (*Simple) GetContractScriptHash added in v0.91.0

func (dao *Simple) GetContractScriptHash(id int32) (util.Uint160, error)

GetContractScriptHash retrieves contract's hash given its ID.

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 util.Uint256, err error)

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

func (*Simple) GetHeaderHashes

func (dao *Simple) GetHeaderHashes() ([]util.Uint256, error)

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

func (*Simple) GetMPTBatch added in v0.94.0

func (dao *Simple) GetMPTBatch() mpt.Batch

GetMPTBatch storage changes to be applied to MPT.

func (*Simple) GetStateSyncCurrentBlockHeight added in v0.97.2

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

GetStateSyncCurrentBlockHeight returns current block height stored during state synchronisation process.

func (*Simple) GetStateSyncPoint added in v0.97.2

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

GetStateSyncPoint returns current state synchronisation point P.

func (*Simple) GetStorageItem

func (dao *Simple) GetStorageItem(id int32, key []byte) state.StorageItem

GetStorageItem returns StorageItem if it exists in the given store.

func (*Simple) GetStorageItems

func (dao *Simple) GetStorageItems(id int32) ([]state.StorageItemWithKey, error)

GetStorageItems returns all storage items for a given id.

func (*Simple) GetStorageItemsWithPrefix added in v0.90.0

func (dao *Simple) GetStorageItemsWithPrefix(id int32, prefix []byte) ([]state.StorageItemWithKey, error)

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

func (*Simple) GetTokenTransferInfo added in v0.98.0

func (dao *Simple) GetTokenTransferInfo(acc util.Uint160) (*state.TokenTransferInfo, error)

GetTokenTransferInfo retrieves NEP-17 transfer info from the cache.

func (*Simple) GetTokenTransferLog added in v0.98.0

func (dao *Simple) GetTokenTransferLog(acc util.Uint160, index uint32, isNEP11 bool) (*state.TokenTransferLog, error)

GetTokenTransferLog retrieves transfer log from the cache.

func (*Simple) GetTransaction

func (dao *Simple) GetTransaction(hash util.Uint256) (*transaction.Transaction, uint32, 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() DAO

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

func (*Simple) HasTransaction

func (dao *Simple) HasTransaction(hash util.Uint256) 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 added in v0.98.0

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

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

Put performs put operation with serializable structures.

func (*Simple) PutAppExecResult

func (dao *Simple) PutAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error

PutAppExecResult puts given application execution result into the given store. It can reuse given buffer for the purpose of value serialization.

func (*Simple) PutContractID added in v0.92.0

func (dao *Simple) PutContractID(id int32, hash util.Uint160) error

PutContractID adds a mapping from contract's ID to its hash.

func (*Simple) PutCurrentHeader

func (dao *Simple) PutCurrentHeader(hashAndIndex []byte) error

PutCurrentHeader stores current header.

func (*Simple) PutStateSyncCurrentBlockHeight added in v0.97.2

func (dao *Simple) PutStateSyncCurrentBlockHeight(h uint32) error

PutStateSyncCurrentBlockHeight stores current block height during state synchronisation process.

func (*Simple) PutStateSyncPoint added in v0.97.2

func (dao *Simple) PutStateSyncPoint(p uint32) error

PutStateSyncPoint stores current state synchronisation point P.

func (*Simple) PutStorageItem

func (dao *Simple) PutStorageItem(id int32, key []byte, si state.StorageItem) error

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

func (*Simple) PutTokenTransferInfo added in v0.98.0

func (dao *Simple) PutTokenTransferInfo(acc util.Uint160, bs *state.TokenTransferInfo) error

PutTokenTransferInfo saves NEP-17 transfer info in the cache.

func (*Simple) PutTokenTransferLog added in v0.98.0

func (dao *Simple) PutTokenTransferLog(acc util.Uint160, index uint32, isNEP11 bool, lg *state.TokenTransferLog) error

PutTokenTransferLog saves given transfer log in the cache.

func (*Simple) PutVersion

func (dao *Simple) PutVersion(v Version) error

PutVersion stores the given version in the underlying store.

func (*Simple) Seek added in v0.92.0

func (dao *Simple) Seek(id int32, prefix []byte, f func(k, v []byte))

Seek executes f for all items with a given prefix. If key is to be used outside of f, they may not be copied.

func (*Simple) SeekAsync added in v0.98.0

func (dao *Simple) SeekAsync(ctx context.Context, id int32, prefix []byte) chan storage.KeyValue

SeekAsync sends all storage items matching given prefix 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, buf *io.BufBinWriter) error

StoreAsBlock stores given block as DataBlock. It can reuse given buffer for the purpose of value serialization.

func (*Simple) StoreAsCurrentBlock

func (dao *Simple) StoreAsCurrentBlock(block *block.Block, buf *io.BufBinWriter) error

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

func (*Simple) StoreAsTransaction

func (dao *Simple) StoreAsTransaction(tx *transaction.Transaction, index uint32, buf *io.BufBinWriter) error

StoreAsTransaction stores given TX as DataTransaction. It also stores transactions given tx has conflicts with as DataTransaction with dummy version. It can reuse given buffer for the purpose of value serialization.

type Version added in v0.98.0

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

Version represents current dao version.

func (*Version) Bytes added in v0.98.0

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

Bytes encodes v to a byte-slice.

func (*Version) FromBytes added in v0.98.0

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