Documentation
¶
Index ¶
- type Cached
- func (cd *Cached) AppendNEP5Transfer(acc util.Uint160, index uint32, tr *state.NEP5Transfer) (bool, error)
- func (cd *Cached) DeleteContractState(hash util.Uint160) error
- func (cd *Cached) GetAccountState(hash util.Uint160) (*state.Account, error)
- func (cd *Cached) GetAccountStateOrNew(hash util.Uint160) (*state.Account, error)
- func (cd *Cached) GetContractState(hash util.Uint160) (*state.Contract, error)
- func (cd *Cached) GetNEP5Balances(acc util.Uint160) (*state.NEP5Balances, error)
- func (cd *Cached) GetNEP5TransferLog(acc util.Uint160, index uint32) (*state.NEP5TransferLog, error)
- func (cd *Cached) GetWrapped() DAO
- func (cd *Cached) Persist() (int, error)
- func (cd *Cached) PutAccountState(as *state.Account) error
- func (cd *Cached) PutContractState(cs *state.Contract) error
- func (cd *Cached) PutNEP5Balances(acc util.Uint160, bs *state.NEP5Balances) error
- func (cd *Cached) PutNEP5TransferLog(acc util.Uint160, index uint32, bs *state.NEP5TransferLog) error
- type DAO
- type Simple
- func (dao *Simple) AppendNEP5Transfer(acc util.Uint160, index uint32, tr *state.NEP5Transfer) (bool, error)
- func (dao *Simple) DeleteContractState(hash util.Uint160) error
- func (dao *Simple) DeleteStorageItem(id int32, key []byte) error
- func (dao *Simple) GetAccountState(hash util.Uint160) (*state.Account, error)
- func (dao *Simple) GetAccountStateOrNew(hash util.Uint160) (*state.Account, error)
- func (dao *Simple) GetAndDecode(entity io.Serializable, key []byte) error
- func (dao *Simple) GetAndUpdateNextContractID() (int32, error)
- func (dao *Simple) GetAppExecResult(hash util.Uint256) (*state.AppExecResult, error)
- func (dao *Simple) GetBatch() *storage.MemBatch
- func (dao *Simple) GetBlock(hash util.Uint256) (*block.Block, error)
- func (dao *Simple) GetContractState(hash util.Uint160) (*state.Contract, error)
- func (dao *Simple) GetCurrentBlockHeight() (uint32, error)
- func (dao *Simple) GetCurrentHeaderHeight() (i uint32, h util.Uint256, err error)
- func (dao *Simple) GetHeaderHashes() ([]util.Uint256, error)
- func (dao *Simple) GetNEP5Balances(acc util.Uint160) (*state.NEP5Balances, error)
- func (dao *Simple) GetNEP5TransferLog(acc util.Uint160, index uint32) (*state.NEP5TransferLog, 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) bool
- func (dao *Simple) Persist() (int, error)
- func (dao *Simple) Put(entity io.Serializable, key []byte) error
- func (dao *Simple) PutAccountState(as *state.Account) error
- func (dao *Simple) PutAppExecResult(aer *state.AppExecResult) error
- func (dao *Simple) PutContractState(cs *state.Contract) error
- func (dao *Simple) PutCurrentHeader(hashAndIndex []byte) error
- func (dao *Simple) PutNEP5Balances(acc util.Uint160, bs *state.NEP5Balances) error
- func (dao *Simple) PutNEP5TransferLog(acc util.Uint160, index uint32, lg *state.NEP5TransferLog) error
- func (dao *Simple) PutStorageItem(id int32, key []byte, si *state.StorageItem) error
- func (dao *Simple) PutVersion(v string) error
- func (dao *Simple) StoreAsBlock(block *block.Block) error
- func (dao *Simple) StoreAsCurrentBlock(block *block.Block) error
- func (dao *Simple) StoreAsTransaction(tx *transaction.Transaction, index uint32) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 read cache for contracts. These are the most frequently used objects in the storeBlock().
func NewCached ¶
func NewCached(d DAO) *Cached
NewCached returns new Cached wrapping around given backing store.
func (*Cached) AppendNEP5Transfer ¶
func (cd *Cached) AppendNEP5Transfer(acc util.Uint160, index uint32, tr *state.NEP5Transfer) (bool, error)
AppendNEP5Transfer appends new transfer to a transfer event log.
func (*Cached) DeleteContractState ¶
func (cd *Cached) DeleteContractState(hash util.Uint160) error
DeleteContractState deletes given contract state in cache and backing store.
func (*Cached) GetAccountState ¶
func (cd *Cached) GetAccountState(hash util.Uint160) (*state.Account, error)
GetAccountState retrieves Account from cache or underlying store.
func (*Cached) GetAccountStateOrNew ¶
func (cd *Cached) GetAccountStateOrNew(hash util.Uint160) (*state.Account, error)
GetAccountStateOrNew retrieves Account from cache or underlying store or creates a new one if it doesn't exist.
func (*Cached) GetContractState ¶
func (cd *Cached) GetContractState(hash util.Uint160) (*state.Contract, error)
GetContractState returns contract state from cache or underlying store.
func (*Cached) GetNEP5Balances ¶
func (cd *Cached) GetNEP5Balances(acc util.Uint160) (*state.NEP5Balances, error)
GetNEP5Balances retrieves NEP5Balances for the acc.
func (*Cached) GetNEP5TransferLog ¶
func (cd *Cached) GetNEP5TransferLog(acc util.Uint160, index uint32) (*state.NEP5TransferLog, error)
GetNEP5TransferLog retrieves NEP5TransferLog for the acc.
func (*Cached) Persist ¶
func (cd *Cached) Persist() (int, error)
Persist flushes all the changes made into the (supposedly) persistent underlying store.
func (*Cached) PutAccountState ¶
func (cd *Cached) PutAccountState(as *state.Account) error
PutAccountState saves given Account in the cache.
func (*Cached) PutContractState ¶
func (cd *Cached) PutContractState(cs *state.Contract) error
PutContractState puts given contract state into the given store.
func (*Cached) PutNEP5Balances ¶
func (cd *Cached) PutNEP5Balances(acc util.Uint160, bs *state.NEP5Balances) error
PutNEP5Balances saves NEP5Balances for the acc.
func (*Cached) PutNEP5TransferLog ¶
func (cd *Cached) PutNEP5TransferLog(acc util.Uint160, index uint32, bs *state.NEP5TransferLog) error
PutNEP5TransferLog saves NEP5TransferLog for the acc.
type DAO ¶
type DAO interface {
AppendNEP5Transfer(acc util.Uint160, index uint32, tr *state.NEP5Transfer) (bool, error)
DeleteContractState(hash util.Uint160) error
DeleteStorageItem(id int32, key []byte) error
GetAccountState(hash util.Uint160) (*state.Account, error)
GetAccountStateOrNew(hash util.Uint160) (*state.Account, error)
GetAndDecode(entity io.Serializable, key []byte) error
GetAppExecResult(hash util.Uint256) (*state.AppExecResult, error)
GetBatch() *storage.MemBatch
GetBlock(hash util.Uint256) (*block.Block, error)
GetContractState(hash util.Uint160) (*state.Contract, error)
GetCurrentBlockHeight() (uint32, error)
GetCurrentHeaderHeight() (i uint32, h util.Uint256, err error)
GetHeaderHashes() ([]util.Uint256, error)
GetNEP5Balances(acc util.Uint160) (*state.NEP5Balances, error)
GetNEP5TransferLog(acc util.Uint160, index uint32) (*state.NEP5TransferLog, error)
GetAndUpdateNextContractID() (int32, 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) bool
Persist() (int, error)
PutAccountState(as *state.Account) error
PutAppExecResult(aer *state.AppExecResult) error
PutContractState(cs *state.Contract) error
PutCurrentHeader(hashAndIndex []byte) error
PutNEP5Balances(acc util.Uint160, bs *state.NEP5Balances) error
PutNEP5TransferLog(acc util.Uint160, index uint32, lg *state.NEP5TransferLog) error
PutStorageItem(id int32, key []byte, si *state.StorageItem) error
PutVersion(v string) error
StoreAsBlock(block *block.Block) error
StoreAsCurrentBlock(block *block.Block) error
StoreAsTransaction(tx *transaction.Transaction, index uint32) error
// contains filtered or unexported methods
}
DAO is a data access object.
type Simple ¶
type Simple struct {
Store *storage.MemCachedStore
// contains filtered or unexported fields
}
Simple is memCached wrapper around DB, simple DAO implementation.
func NewSimple ¶
func NewSimple(backend storage.Store, network netmode.Magic) *Simple
NewSimple creates new simple dao using provided backend store.
func (*Simple) AppendNEP5Transfer ¶
func (dao *Simple) AppendNEP5Transfer(acc util.Uint160, index uint32, tr *state.NEP5Transfer) (bool, error)
AppendNEP5Transfer appends a single NEP5 transfer to a log. First return value signalizes that log size has exceeded batch size.
func (*Simple) DeleteContractState ¶
func (dao *Simple) DeleteContractState(hash util.Uint160) error
DeleteContractState deletes given contract state in the given store.
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) GetAccountState ¶
func (dao *Simple) GetAccountState(hash util.Uint160) (*state.Account, error)
GetAccountState returns Account from the given Store if it's present there. Returns nil otherwise.
func (*Simple) GetAccountStateOrNew ¶
func (dao *Simple) GetAccountStateOrNew(hash util.Uint160) (*state.Account, error)
GetAccountStateOrNew retrieves Account from temporary or persistent Store or creates a new one if it doesn't exist and persists it.
func (*Simple) GetAndDecode ¶
func (dao *Simple) GetAndDecode(entity io.Serializable, key []byte) error
GetAndDecode performs get operation and decoding with serializable structures.
func (*Simple) GetAndUpdateNextContractID ¶ added in v0.90.0
func (dao *Simple) GetAndUpdateNextContractID() (int32, error)
GetAndUpdateNextContractID returns id for the next contract and increases stored ID.
func (*Simple) GetAppExecResult ¶
func (dao *Simple) GetAppExecResult(hash util.Uint256) (*state.AppExecResult, error)
GetAppExecResult gets application execution result 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) GetContractState ¶
func (dao *Simple) GetContractState(hash util.Uint160) (*state.Contract, error)
GetContractState returns contract state as recorded in the given store by the given script hash.
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) GetNEP5Balances ¶
func (dao *Simple) GetNEP5Balances(acc util.Uint160) (*state.NEP5Balances, error)
GetNEP5Balances retrieves nep5 balances from the cache.
func (*Simple) GetNEP5TransferLog ¶
func (dao *Simple) GetNEP5TransferLog(acc util.Uint160, index uint32) (*state.NEP5TransferLog, error)
GetNEP5TransferLog retrieves transfer log from the cache.
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) (map[string]*state.StorageItem, 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) (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.
func (*Simple) GetVersion ¶
func (dao *Simple) GetVersion() (string, 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) bool
HasTransaction returns true if the given store contains the given Transaction hash.
func (*Simple) Persist ¶
func (dao *Simple) Persist() (int, error)
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) PutAccountState ¶
func (dao *Simple) PutAccountState(as *state.Account) error
PutAccountState saves given Account in given store.
func (*Simple) PutAppExecResult ¶
func (dao *Simple) PutAppExecResult(aer *state.AppExecResult) error
PutAppExecResult puts given application execution result into the given store.
func (*Simple) PutContractState ¶
func (dao *Simple) PutContractState(cs *state.Contract) error
PutContractState puts given contract state into the given store.
func (*Simple) PutCurrentHeader ¶
func (dao *Simple) PutCurrentHeader(hashAndIndex []byte) error
PutCurrentHeader stores current header.
func (*Simple) PutNEP5Balances ¶
func (dao *Simple) PutNEP5Balances(acc util.Uint160, bs *state.NEP5Balances) error
PutNEP5Balances saves nep5 balances from the cache.
func (*Simple) PutNEP5TransferLog ¶
func (dao *Simple) PutNEP5TransferLog(acc util.Uint160, index uint32, lg *state.NEP5TransferLog) error
PutNEP5TransferLog saves given transfer log in the cache.
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) PutVersion ¶
func (dao *Simple) PutVersion(v string) error
PutVersion stores the given version in the underlying store.
func (*Simple) StoreAsBlock ¶
func (dao *Simple) StoreAsBlock(block *block.Block) error
StoreAsBlock stores the given block as DataBlock.
func (*Simple) StoreAsCurrentBlock ¶
func (dao *Simple) StoreAsCurrentBlock(block *block.Block) error
StoreAsCurrentBlock stores the given block witch prefix SYSCurrentBlock.
func (*Simple) StoreAsTransaction ¶
func (dao *Simple) StoreAsTransaction(tx *transaction.Transaction, index uint32) error
StoreAsTransaction stores the given TX as DataTransaction.