Documentation ¶
Index ¶
- Constants
- Variables
- func IsValuable(log *types.ChangeLog) bool
- func MergeChangeLogs(logs types.ChangeLogSlice) types.ChangeLogSlice
- func NewAddEventLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- func NewBalanceLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- func NewCandidateProfileLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- func NewCodeLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- func NewStorageLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) (*types.ChangeLog, error)
- func NewSuicideLog(processor types.ChangeLogProcessor, account types.AccountAccessor) *types.ChangeLog
- func NewTxCountLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- func NewVoteForLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- func NewVotesLog(processor types.ChangeLogProcessor, account types.AccountAccessor, ...) *types.ChangeLog
- type Account
- func (a *Account) Finalise() error
- func (a *Account) GetAddress() common.Address
- func (a *Account) GetBalance() *big.Int
- func (a *Account) GetBaseVersion(logType types.ChangeLogType) uint32
- func (a *Account) GetCandidateProfile() types.CandidateProfile
- func (a *Account) GetCode() (types.Code, error)
- func (a *Account) GetCodeHash() common.Hash
- func (a *Account) GetStorageRoot() common.Hash
- func (a *Account) GetStorageState(key common.Hash) ([]byte, error)
- func (a *Account) GetSuicide() bool
- func (a *Account) GetTxCount() uint32
- func (a *Account) GetVoteFor() common.Address
- func (a *Account) GetVotes() *big.Int
- func (a *Account) IsEmpty() bool
- func (a *Account) MarshalJSON() ([]byte, error)
- func (a *Account) Save() error
- func (a *Account) SetBalance(balance *big.Int)
- func (a *Account) SetCandidateProfile(profile types.CandidateProfile)
- func (a *Account) SetCode(code types.Code)
- func (a *Account) SetCodeHash(codeHash common.Hash)
- func (a *Account) SetStorageRoot(root common.Hash)
- func (a *Account) SetStorageState(key common.Hash, value []byte) error
- func (a *Account) SetSuicide(suicided bool)
- func (a *Account) SetTxCount(count uint32)
- func (a *Account) SetVersion(logType types.ChangeLogType, version, blockHeight uint32)
- func (a *Account) SetVoteFor(addr common.Address)
- func (a *Account) SetVotes(votes *big.Int)
- func (a *Account) String() string
- func (a *Account) UnmarshalJSON(input []byte) error
- type LogProcessor
- func (h *LogProcessor) Clear()
- func (h *LogProcessor) GetAccount(addr common.Address) types.AccountAccessor
- func (h *LogProcessor) GetChangeLogs() []*types.ChangeLog
- func (h *LogProcessor) GetEvents() []*types.Event
- func (h *LogProcessor) GetLogsByAddress(address common.Address) []*types.ChangeLog
- func (h *LogProcessor) GetNextVersion(logType types.ChangeLogType, addr common.Address) uint32
- func (h *LogProcessor) MergeChangeLogs(fromIndex int)
- func (h *LogProcessor) PopEvent() error
- func (h *LogProcessor) PushChangeLog(log *types.ChangeLog)
- func (h *LogProcessor) PushEvent(event *types.Event)
- func (h *LogProcessor) Rebuild(address common.Address, logs types.ChangeLogSlice) (*Account, error)
- func (h *LogProcessor) RevertToSnapshot(revid int)
- func (h *LogProcessor) Snapshot() int
- type Manager
- func (am *Manager) AddEvent(event *types.Event)
- func (am *Manager) Finalise() error
- func (am *Manager) GetAccount(address common.Address) types.AccountAccessor
- func (am *Manager) GetCanonicalAccount(address common.Address) types.AccountAccessor
- func (am *Manager) GetChangeLogs() []*types.ChangeLog
- func (am *Manager) GetEvents() []*types.Event
- func (am *Manager) GetEventsByTx(txHash common.Hash) []*types.Event
- func (am *Manager) GetVersionRoot() common.Hash
- func (am *Manager) IsExist(address common.Address) bool
- func (am *Manager) MergeChangeLogs(fromIndex int)
- func (am *Manager) Rebuild(address common.Address, logs types.ChangeLogSlice) error
- func (am *Manager) Reset(blockHash common.Hash)
- func (am *Manager) RevertToSnapshot(revid int)
- func (am *Manager) Save(newBlockHash common.Hash) error
- func (am *Manager) Snapshot() int
- func (am *Manager) Stop(graceful bool) error
- type RawAccountLoader
- type SafeAccount
- func (a *SafeAccount) GetAddress() common.Address
- func (a *SafeAccount) GetBalance() *big.Int
- func (a *SafeAccount) GetBaseVersion(logType types.ChangeLogType) uint32
- func (a *SafeAccount) GetCandidateProfile() types.CandidateProfile
- func (a *SafeAccount) GetCode() (types.Code, error)
- func (a *SafeAccount) GetCodeHash() common.Hash
- func (a *SafeAccount) GetStorageRoot() common.Hash
- func (a *SafeAccount) GetStorageState(key common.Hash) ([]byte, error)
- func (a *SafeAccount) GetSuicide() bool
- func (a *SafeAccount) GetTxCount() uint32
- func (a *SafeAccount) GetVoteFor() common.Address
- func (a *SafeAccount) GetVotes() *big.Int
- func (a *SafeAccount) IsDirty() bool
- func (a *SafeAccount) IsEmpty() bool
- func (a *SafeAccount) MarshalJSON() ([]byte, error)
- func (a *SafeAccount) SetBalance(balance *big.Int)
- func (a *SafeAccount) SetCandidateProfile(profile types.CandidateProfile)
- func (a *SafeAccount) SetCode(code types.Code)
- func (a *SafeAccount) SetCodeHash(codeHash common.Hash)
- func (a *SafeAccount) SetStorageRoot(root common.Hash)
- func (a *SafeAccount) SetStorageState(key common.Hash, value []byte) error
- func (a *SafeAccount) SetSuicide(suicided bool)
- func (a *SafeAccount) SetTxCount(count uint32)
- func (a *SafeAccount) SetVoteFor(addr common.Address)
- func (a *SafeAccount) SetVotes(votes *big.Int)
- func (a *SafeAccount) String() string
- func (a *SafeAccount) UnmarshalJSON(input []byte) error
- type Storage
Constants ¶
const ( BalanceLog types.ChangeLogType = iota + 1 StorageLog CodeLog AddEventLog SuicideLog VoteForLog VotesLog CandidateProfileLog TxCountLog LOG_TYPE_STOP )
const MaxTrieCacheGen = uint16(120)
Trie cache generation limit after which to evict trie nodes from memory.
Variables ¶
Functions ¶
func IsValuable ¶
IsValuable returns true if the change log contains some data change
func MergeChangeLogs ¶
func MergeChangeLogs(logs types.ChangeLogSlice) types.ChangeLogSlice
MergeChangeLogs merges the change logs for same account in block. Then return the merged change logs.
func NewAddEventLog ¶
func NewAddEventLog(processor types.ChangeLogProcessor, account types.AccountAccessor, newEvent *types.Event) *types.ChangeLog
NewAddEventLog records contract code change
func NewBalanceLog ¶
func NewBalanceLog(processor types.ChangeLogProcessor, account types.AccountAccessor, newBalance *big.Int) *types.ChangeLog
NewBalanceLog records balance change
func NewCandidateProfileLog ¶ added in v1.1.0
func NewCandidateProfileLog(processor types.ChangeLogProcessor, account types.AccountAccessor, newProfile types.CandidateProfile) *types.ChangeLog
func NewCodeLog ¶
func NewCodeLog(processor types.ChangeLogProcessor, account types.AccountAccessor, code types.Code) *types.ChangeLog
NewCodeLog records contract code setting
func NewStorageLog ¶
func NewStorageLog(processor types.ChangeLogProcessor, account types.AccountAccessor, key common.Hash, newVal []byte) (*types.ChangeLog, error)
NewStorageLog records contract storage value change
func NewSuicideLog ¶
func NewSuicideLog(processor types.ChangeLogProcessor, account types.AccountAccessor) *types.ChangeLog
NewSuicideLog records balance change
func NewTxCountLog ¶ added in v1.1.0
func NewTxCountLog(processor types.ChangeLogProcessor, account types.AccountAccessor, newTxCount uint32) *types.ChangeLog
func NewVoteForLog ¶ added in v1.1.0
func NewVoteForLog(processor types.ChangeLogProcessor, account types.AccountAccessor, newVoteFor common.Address) *types.ChangeLog
func NewVotesLog ¶ added in v1.1.0
func NewVotesLog(processor types.ChangeLogProcessor, account types.AccountAccessor, newVotes *big.Int) *types.ChangeLog
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account is used to read and write account data. the code and dirty storage K/V would be cached till they are flushing to db
func NewAccount ¶
NewAccount wrap an AccountData object, or creates a new one if it's nil.
func (*Account) GetAddress ¶
Implement AccountAccessor. Access Account without changelog
func (*Account) GetBalance ¶
func (*Account) GetBaseVersion ¶ added in v1.0.2
func (a *Account) GetBaseVersion(logType types.ChangeLogType) uint32
GetBaseVersion returns the version of specific change log from the base block. It is not changed by tx processing until the finalised
func (*Account) GetCandidateProfile ¶ added in v1.1.0
func (a *Account) GetCandidateProfile() types.CandidateProfile
func (*Account) GetCodeHash ¶
func (*Account) GetStorageRoot ¶
StorageRoot wouldn't change until Account.updateTrie() is called
func (*Account) GetStorageState ¶
GetState returns a value in account storage.
func (*Account) GetSuicide ¶
func (*Account) GetTxCount ¶ added in v1.1.0
func (*Account) GetVoteFor ¶ added in v1.1.0
func (*Account) IsEmpty ¶
IsEmpty returns whether the state object is either non-existent or empty (version = 0)
func (*Account) MarshalJSON ¶
MarshalJSON encodes the lemoClient RPC account format.
func (*Account) SetBalance ¶
func (*Account) SetCandidateProfile ¶ added in v1.1.0
func (a *Account) SetCandidateProfile(profile types.CandidateProfile)
func (*Account) SetCodeHash ¶
func (*Account) SetStorageRoot ¶
func (*Account) SetStorageState ¶
SetState updates a value in account storage.
func (*Account) SetSuicide ¶
func (*Account) SetTxCount ¶ added in v1.1.0
func (*Account) SetVersion ¶
func (a *Account) SetVersion(logType types.ChangeLogType, version, blockHeight uint32)
func (*Account) SetVoteFor ¶ added in v1.1.0
func (*Account) UnmarshalJSON ¶
UnmarshalJSON decodes the lemoClient RPC account format.
type LogProcessor ¶ added in v1.0.2
type LogProcessor struct {
// contains filtered or unexported fields
}
LogProcessor records change logs and contract events during block's transaction execution. It can access raw account data for undo/redo
func NewLogProcessor ¶ added in v1.0.2
func NewLogProcessor(accountLoader RawAccountLoader) *LogProcessor
NewLogProcessor creates a new LogProcessor. It is used to maintain change logs queue
func (*LogProcessor) Clear ¶ added in v1.0.2
func (h *LogProcessor) Clear()
func (*LogProcessor) GetAccount ¶ added in v1.0.2
func (h *LogProcessor) GetAccount(addr common.Address) types.AccountAccessor
func (*LogProcessor) GetChangeLogs ¶ added in v1.0.2
func (h *LogProcessor) GetChangeLogs() []*types.ChangeLog
func (*LogProcessor) GetEvents ¶ added in v1.0.2
func (h *LogProcessor) GetEvents() []*types.Event
func (*LogProcessor) GetLogsByAddress ¶ added in v1.0.2
func (h *LogProcessor) GetLogsByAddress(address common.Address) []*types.ChangeLog
func (*LogProcessor) GetNextVersion ¶ added in v1.0.2
func (h *LogProcessor) GetNextVersion(logType types.ChangeLogType, addr common.Address) uint32
GetNextVersion generate new version for change log
func (*LogProcessor) MergeChangeLogs ¶ added in v1.0.2
func (h *LogProcessor) MergeChangeLogs(fromIndex int)
MergeChangeLogs merges the change logs for same account in block
func (*LogProcessor) PopEvent ¶ added in v1.0.2
func (h *LogProcessor) PopEvent() error
func (*LogProcessor) PushChangeLog ¶ added in v1.0.2
func (h *LogProcessor) PushChangeLog(log *types.ChangeLog)
func (*LogProcessor) PushEvent ¶ added in v1.0.2
func (h *LogProcessor) PushEvent(event *types.Event)
func (*LogProcessor) Rebuild ¶ added in v1.0.2
func (h *LogProcessor) Rebuild(address common.Address, logs types.ChangeLogSlice) (*Account, error)
Rebuild loads and redo all change logs to update account to the newest state.
func (*LogProcessor) RevertToSnapshot ¶ added in v1.0.2
func (h *LogProcessor) RevertToSnapshot(revid int)
RevertToSnapshot reverts all changes made since the given revision.
func (*LogProcessor) Snapshot ¶ added in v1.0.2
func (h *LogProcessor) Snapshot() int
Snapshot returns an identifier for the current revision of the change log.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is used to maintain the newest and not confirmed account data. It will save all data to the db when finished a block's transactions processing.
func NewManager ¶
NewManager creates a new Manager. It is used to maintain account changes based on the block environment which specified by blockHash
func ReadOnlyManager ¶ added in v1.1.0
ReadOnlyManager
func (*Manager) GetAccount ¶
func (am *Manager) GetAccount(address common.Address) types.AccountAccessor
GetAccount loads account from cache or db, or creates a new one if it's not exist.
func (*Manager) GetCanonicalAccount ¶
func (am *Manager) GetCanonicalAccount(address common.Address) types.AccountAccessor
GetCanonicalAccount loads an readonly account object from confirmed block in db, or creates a new one if it's not exist. The Modification of the account will not be recorded to store.
func (*Manager) GetChangeLogs ¶
GetChangeLogs returns all change logs since last reset
func (*Manager) GetEventsByTx ¶
GetEvents returns all events since last reset
func (*Manager) GetVersionRoot ¶
func (*Manager) IsExist ¶
IsExist reports whether the given account address exists in the db. Notably this also returns true for suicided accounts.
func (*Manager) MergeChangeLogs ¶
MergeChangeLogs merges the change logs for same account in block. Then update the version of change logs and account.
func (*Manager) Rebuild ¶
Rebuild loads and redo all change logs to update account to the newest state.
func (*Manager) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
type RawAccountLoader ¶ added in v1.0.2
type RawAccountLoader interface {
// contains filtered or unexported methods
}
type SafeAccount ¶
type SafeAccount struct {
// contains filtered or unexported fields
}
SafeAccount is used to record modifications with changelog. So that the modifications can be reverted
func NewSafeAccount ¶
func NewSafeAccount(processor *LogProcessor, account *Account) *SafeAccount
NewSafeAccount creates an account object.
func (*SafeAccount) GetAddress ¶
func (a *SafeAccount) GetAddress() common.Address
func (*SafeAccount) GetBalance ¶
func (a *SafeAccount) GetBalance() *big.Int
func (*SafeAccount) GetBaseVersion ¶ added in v1.0.2
func (a *SafeAccount) GetBaseVersion(logType types.ChangeLogType) uint32
GetBaseVersion returns the version of specific change log from the base block. It is not changed by tx processing until the finalised
func (*SafeAccount) GetCandidateProfile ¶ added in v1.1.0
func (a *SafeAccount) GetCandidateProfile() types.CandidateProfile
func (*SafeAccount) GetCodeHash ¶
func (a *SafeAccount) GetCodeHash() common.Hash
func (*SafeAccount) GetStorageRoot ¶
func (a *SafeAccount) GetStorageRoot() common.Hash
func (*SafeAccount) GetStorageState ¶
func (a *SafeAccount) GetStorageState(key common.Hash) ([]byte, error)
func (*SafeAccount) GetSuicide ¶
func (a *SafeAccount) GetSuicide() bool
func (*SafeAccount) GetTxCount ¶ added in v1.1.0
func (a *SafeAccount) GetTxCount() uint32
func (*SafeAccount) GetVoteFor ¶ added in v1.1.0
func (a *SafeAccount) GetVoteFor() common.Address
func (*SafeAccount) GetVotes ¶ added in v1.1.0
func (a *SafeAccount) GetVotes() *big.Int
func (*SafeAccount) IsDirty ¶
func (a *SafeAccount) IsDirty() bool
func (*SafeAccount) IsEmpty ¶
func (a *SafeAccount) IsEmpty() bool
func (*SafeAccount) MarshalJSON ¶
func (a *SafeAccount) MarshalJSON() ([]byte, error)
MarshalJSON encodes the lemoClient RPC safeAccount format.
func (*SafeAccount) SetBalance ¶
func (a *SafeAccount) SetBalance(balance *big.Int)
overwrite Account.SetXXX. Access Account with changelog
func (*SafeAccount) SetCandidateProfile ¶ added in v1.1.0
func (a *SafeAccount) SetCandidateProfile(profile types.CandidateProfile)
func (*SafeAccount) SetCode ¶
func (a *SafeAccount) SetCode(code types.Code)
func (*SafeAccount) SetCodeHash ¶
func (a *SafeAccount) SetCodeHash(codeHash common.Hash)
func (*SafeAccount) SetStorageRoot ¶
func (a *SafeAccount) SetStorageRoot(root common.Hash)
func (*SafeAccount) SetStorageState ¶
func (a *SafeAccount) SetStorageState(key common.Hash, value []byte) error
func (*SafeAccount) SetSuicide ¶
func (a *SafeAccount) SetSuicide(suicided bool)
func (*SafeAccount) SetTxCount ¶ added in v1.1.0
func (a *SafeAccount) SetTxCount(count uint32)
func (*SafeAccount) SetVoteFor ¶ added in v1.1.0
func (a *SafeAccount) SetVoteFor(addr common.Address)
func (*SafeAccount) SetVotes ¶ added in v1.1.0
func (a *SafeAccount) SetVotes(votes *big.Int)
func (*SafeAccount) String ¶
func (a *SafeAccount) String() string
func (*SafeAccount) UnmarshalJSON ¶
func (a *SafeAccount) UnmarshalJSON(input []byte) error
UnmarshalJSON decodes the lemoClient RPC safeAccount format.