Documentation
¶
Index ¶
- Variables
- type Cached
- func (cd *Cached) AppendNEP17Transfer(acc util.Uint160, index uint32, tr *state.NEP17Transfer) (bool, error)
- func (cd *Cached) GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, error)
- func (cd *Cached) GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error)
- func (cd *Cached) GetWrapped() DAO
- func (cd *Cached) Persist() (int, error)
- func (cd *Cached) PutNEP17Balances(acc util.Uint160, bs *state.NEP17Balances) error
- func (cd *Cached) PutNEP17TransferLog(acc util.Uint160, index uint32, bs *state.NEP17TransferLog) error
- type DAO
- type Simple
- func (dao *Simple) AppendAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error
- func (dao *Simple) AppendNEP17Transfer(acc util.Uint160, index uint32, tr *state.NEP17Transfer) (bool, error)
- func (dao *Simple) DeleteBlock(h util.Uint256, w *io.BufBinWriter) error
- func (dao *Simple) DeleteContractID(id int32) error
- func (dao *Simple) DeleteStorageItem(id int32, key []byte) error
- func (dao *Simple) GetAndDecode(entity io.Serializable, key []byte) error
- func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]state.AppExecResult, error)
- func (dao *Simple) GetBatch() *storage.MemBatch
- func (dao *Simple) GetBlock(hash util.Uint256) (*block.Block, error)
- func (dao *Simple) GetContractScriptHash(id int32) (util.Uint160, error)
- func (dao *Simple) GetCurrentBlockHeight() (uint32, error)
- func (dao *Simple) GetCurrentHeaderHeight() (i uint32, h util.Uint256, err error)
- func (dao *Simple) GetCurrentStateRootHeight() (uint32, error)
- func (dao *Simple) GetHeaderHashes() ([]util.Uint256, error)
- func (dao *Simple) GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, error)
- func (dao *Simple) GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error)
- func (dao *Simple) GetStateRoot(height uint32) (*state.MPTRootState, error)
- func (dao *Simple) GetStorageItem(id int32, key []byte) *state.StorageItem
- func (dao *Simple) GetStorageItems(id int32) (map[string]*state.StorageItem, error)
- func (dao *Simple) GetStorageItemsWithPrefix(id int32, prefix []byte) (map[string]*state.StorageItem, error)
- func (dao *Simple) GetTransaction(hash util.Uint256) (*transaction.Transaction, uint32, error)
- func (dao *Simple) GetVersion() (string, error)
- func (dao *Simple) GetWrapped() DAO
- func (dao *Simple) HasTransaction(hash util.Uint256) error
- func (dao *Simple) InitMPT(height uint32, enableRefCount bool) error
- func (dao *Simple) Persist() (int, error)
- func (dao *Simple) Put(entity io.Serializable, key []byte) error
- func (dao *Simple) PutAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error
- func (dao *Simple) PutContractID(id int32, hash util.Uint160) error
- func (dao *Simple) PutCurrentHeader(hashAndIndex []byte) error
- func (dao *Simple) PutCurrentStateRootHeight(height uint32) error
- func (dao *Simple) PutNEP17Balances(acc util.Uint160, bs *state.NEP17Balances) error
- func (dao *Simple) PutNEP17TransferLog(acc util.Uint160, index uint32, lg *state.NEP17TransferLog) error
- func (dao *Simple) PutStateRoot(r *state.MPTRootState) error
- func (dao *Simple) PutStorageItem(id int32, key []byte, si *state.StorageItem) error
- func (dao *Simple) PutVersion(v string) error
- func (dao *Simple) Seek(id int32, prefix []byte, f func(k, v []byte))
- func (dao *Simple) StoreAsBlock(block *block.Block, buf *io.BufBinWriter) error
- func (dao *Simple) StoreAsCurrentBlock(block *block.Block, buf *io.BufBinWriter) error
- func (dao *Simple) StoreAsTransaction(tx *transaction.Transaction, index uint32, buf *io.BufBinWriter) error
- func (dao *Simple) UpdateMPT() error
Constants ¶
This section is empty.
Variables ¶
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 Cached ¶
type Cached struct { DAO // contains filtered or unexported fields }
Cached is a data access object that mimics DAO, but has a write cache for accounts and NEP17 transfer data. These are the most frequently used objects in the storeBlock().
func (*Cached) AppendNEP17Transfer ¶ added in v0.92.0
func (cd *Cached) AppendNEP17Transfer(acc util.Uint160, index uint32, tr *state.NEP17Transfer) (bool, error)
AppendNEP17Transfer appends new transfer to a transfer event log.
func (*Cached) GetNEP17Balances ¶ added in v0.92.0
GetNEP17Balances retrieves NEP17Balances for the acc.
func (*Cached) GetNEP17TransferLog ¶ added in v0.92.0
func (cd *Cached) GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error)
GetNEP17TransferLog retrieves NEP17TransferLog for the acc.
func (*Cached) Persist ¶
Persist flushes all the changes made into the (supposedly) persistent underlying store.
func (*Cached) PutNEP17Balances ¶ added in v0.92.0
PutNEP17Balances saves NEP17Balances for the acc.
func (*Cached) PutNEP17TransferLog ¶ added in v0.92.0
func (cd *Cached) PutNEP17TransferLog(acc util.Uint160, index uint32, bs *state.NEP17TransferLog) error
PutNEP17TransferLog saves NEP17TransferLog for the acc.
type DAO ¶
type DAO interface { AppendAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error AppendNEP17Transfer(acc util.Uint160, index uint32, tr *state.NEP17Transfer) (bool, 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) GetCurrentStateRootHeight() (uint32, error) GetHeaderHashes() ([]util.Uint256, error) GetNEP17Balances(acc util.Uint160) (*state.NEP17Balances, error) GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error) GetStateRoot(height uint32) (*state.MPTRootState, error) PutStateRoot(root *state.MPTRootState) error GetStorageItem(id int32, key []byte) *state.StorageItem GetStorageItems(id int32) (map[string]*state.StorageItem, error) GetStorageItemsWithPrefix(id int32, prefix []byte) (map[string]*state.StorageItem, error) GetTransaction(hash util.Uint256) (*transaction.Transaction, uint32, error) GetVersion() (string, error) GetWrapped() DAO HasTransaction(hash util.Uint256) error Persist() (int, error) PutAppExecResult(aer *state.AppExecResult, buf *io.BufBinWriter) error PutContractID(id int32, hash util.Uint160) error PutCurrentHeader(hashAndIndex []byte) error PutNEP17Balances(acc util.Uint160, bs *state.NEP17Balances) error PutNEP17TransferLog(acc util.Uint160, index uint32, lg *state.NEP17TransferLog) error PutStorageItem(id int32, key []byte, si *state.StorageItem) error PutVersion(v string) error Seek(id int32, prefix []byte, f func(k, v []byte)) 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 { MPT *mpt.Trie Store *storage.MemCachedStore // contains filtered or unexported fields }
Simple is memCached wrapper around DB, simple DAO implementation.
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) AppendNEP17Transfer ¶ added in v0.92.0
func (dao *Simple) AppendNEP17Transfer(acc util.Uint160, index uint32, tr *state.NEP17Transfer) (bool, error)
AppendNEP17Transfer appends a single NEP17 transfer to a log. First return value signalizes that log size has exceeded batch size.
func (*Simple) DeleteBlock ¶ added in v0.92.0
DeleteBlock removes block from dao.
func (*Simple) DeleteContractID ¶ added in v0.92.0
DeleteContractID deletes contract's id to hash mapping.
func (*Simple) DeleteStorageItem ¶
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) GetContractScriptHash ¶ added in v0.91.0
GetContractScriptHash retrieves contract's hash given its ID.
func (*Simple) GetCurrentBlockHeight ¶
GetCurrentBlockHeight returns the current block height found in the underlying store.
func (*Simple) GetCurrentHeaderHeight ¶
GetCurrentHeaderHeight returns the current header height and hash from the underlying store.
func (*Simple) GetCurrentStateRootHeight ¶ added in v0.76.0
GetCurrentStateRootHeight returns current state root height.
func (*Simple) GetHeaderHashes ¶
GetHeaderHashes returns a sorted list of header hashes retrieved from the given underlying store.
func (*Simple) GetNEP17Balances ¶ added in v0.92.0
GetNEP17Balances retrieves nep17 balances from the cache.
func (*Simple) GetNEP17TransferLog ¶ added in v0.92.0
func (dao *Simple) GetNEP17TransferLog(acc util.Uint160, index uint32) (*state.NEP17TransferLog, error)
GetNEP17TransferLog retrieves transfer log from the cache.
func (*Simple) GetStateRoot ¶ added in v0.76.0
func (dao *Simple) GetStateRoot(height uint32) (*state.MPTRootState, error)
GetStateRoot returns state root of a given height.
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 ¶
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) (map[string]*state.StorageItem, error)
GetStorageItemsWithPrefix returns all storage items with given id for a given scripthash.
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 ¶
GetVersion attempts to get the current version stored in the underlying store.
func (*Simple) GetWrapped ¶
GetWrapped returns new DAO instance with another layer of wrapped MemCachedStore around the current DAO Store.
func (*Simple) HasTransaction ¶
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 ¶
Persist flushes all the changes made into the (supposedly) persistent underlying 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
PutContractID adds a mapping from contract's ID to its hash.
func (*Simple) PutCurrentHeader ¶
PutCurrentHeader stores current header.
func (*Simple) PutCurrentStateRootHeight ¶ added in v0.76.0
PutCurrentStateRootHeight updates current state root height.
func (*Simple) PutNEP17Balances ¶ added in v0.92.0
PutNEP17Balances saves nep17 balances from the cache.
func (*Simple) PutNEP17TransferLog ¶ added in v0.92.0
func (dao *Simple) PutNEP17TransferLog(acc util.Uint160, index uint32, lg *state.NEP17TransferLog) error
PutNEP17TransferLog saves given transfer log in the cache.
func (*Simple) PutStateRoot ¶ added in v0.76.0
func (dao *Simple) PutStateRoot(r *state.MPTRootState) error
PutStateRoot puts state root of a given height into the store.
func (*Simple) PutStorageItem ¶
PutStorageItem puts given StorageItem for given id with given key into the given store.
func (*Simple) PutVersion ¶
PutVersion stores the given version in the underlying store.
func (*Simple) Seek ¶ added in v0.92.0
Seek executes f for all items with a given prefix. If key is to be used outside of f, they must be copied.
func (*Simple) StoreAsBlock ¶
StoreAsBlock stores given block as DataBlock. It can reuse given buffer for the purpose of value serialization.
func (*Simple) StoreAsCurrentBlock ¶
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 can reuse given buffer for the purpose of value serialization.