state

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountKey

func AccountKey(addr common.Address) common.Bytes

AccountKey constructs the state key for the given address

func ChainIDKey

func ChainIDKey() common.Bytes

ChainIDKey returns the key for chainID

func CodeKey

func CodeKey(codeHash common.Bytes) common.Bytes

CodeKey constructs the state key for the given code hash

func SentryCandidatePoolKey added in v1.0.0

func SentryCandidatePoolKey() common.Bytes

SentryCandidatePoolKey returns the state key for the guadian stake holder set

func SplitRuleKey

func SplitRuleKey(resourceID string) common.Bytes

SplitRuleKey constructs the state key for the given resourceID

func SplitRuleKeyPrefix

func SplitRuleKeyPrefix() common.Bytes

SplitRuleKeyPrefix returns the prefix for the split rule key

func StakeTransactionHeightListKey

func StakeTransactionHeightListKey() common.Bytes

StakeTransactionHeightListKey returns the state key the heights of blocks that contain stake related transactions (i.e. StakeDeposit, StakeWithdraw, etc)

func StatePruningProgressKey

func StatePruningProgressKey() common.Bytes

StatePruningProgressKey returns the key for the state pruning progress

func ValidatorCandidatePoolKey

func ValidatorCandidatePoolKey() common.Bytes

ValidatorCandidatePoolKey returns the state key for the validator stake holder set

Types

type LedgerState

type LedgerState struct {
	// contains filtered or unexported fields
}

func NewLedgerState

func NewLedgerState(chainID string, db database.Database) *LedgerState

NewLedgerState creates a new Leger State with given store. NOTE: before using the LedgerState, we need to call LedgerState.ResetState() to set

the proper height and stateRootHash

func (*LedgerState) Checked

func (s *LedgerState) Checked() *StoreView

Checked creates a fresh clone of delivered view to be used for checking transactions.

func (*LedgerState) Commit

func (s *LedgerState) Commit() common.Hash

Commit stores the current delivered view as committed, starts new delivered/checked state and returns the hash for the commit.

func (*LedgerState) DB

func (s *LedgerState) DB() database.Database

DB returns the database instance of the ledger state

func (*LedgerState) Delivered

func (s *LedgerState) Delivered() *StoreView

Delivered returns a view of current state that contains both committed and delivered transactions.

func (*LedgerState) Finalize

func (s *LedgerState) Finalize(height uint64, stateRootHash common.Hash) result.Result

Finalize updates the finalized view.

func (*LedgerState) Finalized

func (s *LedgerState) Finalized() *StoreView

Finalized creates a fresh clone of delivered view to be used for checking transactions.

func (*LedgerState) GetChainID

func (s *LedgerState) GetChainID() string

GetChainID gets chain ID.

func (*LedgerState) Height

func (s *LedgerState) Height() uint64

Height returns the block height corresponding to the ledger state

func (*LedgerState) ParentBlock

func (s *LedgerState) ParentBlock() *core.Block

ParentBlock returns the pointer to the parent block for the current view

func (*LedgerState) ResetState

func (s *LedgerState) ResetState(block *core.Block) result.Result

ResetState resets the height and state root of its storeviews, and clear the in-memory states func (s *LedgerState) ResetState(height uint64, stateRootHash common.Hash) result.Result

func (*LedgerState) Screened

func (s *LedgerState) Screened() *StoreView

Screened creates a fresh clone of delivered view to be used for checking transactions.

type StoreView

type StoreView struct {
	// contains filtered or unexported fields
}

func NewStoreView

func NewStoreView(height uint64, root common.Hash, db database.Database) *StoreView

NewStoreView creates an instance of the StoreView

func (*StoreView) AddBalance

func (sv *StoreView) AddBalance(addr common.Address, amount *big.Int)

func (*StoreView) AddLog

func (sv *StoreView) AddLog(l *types.Log)

func (*StoreView) AddRefund

func (sv *StoreView) AddRefund(gas uint64)

func (*StoreView) AddSlashIntent

func (sv *StoreView) AddSlashIntent(slashIntent types.SlashIntent)

AddSlashIntent adds slashIntent

func (*StoreView) AddSplitRule

func (sv *StoreView) AddSplitRule(splitRule *types.SplitRule) bool

AddSplitRule adds a split rule

func (*StoreView) ClearSlashIntents

func (sv *StoreView) ClearSlashIntents()

ClearSlashIntents clears all the slashIntents

func (*StoreView) CoinbaseTransactinProcessed

func (sv *StoreView) CoinbaseTransactinProcessed() bool

CoinbaseTransactinProcessed returns whether the coinbase transaction for the current block has been processed

func (*StoreView) Copy

func (sv *StoreView) Copy() (*StoreView, error)

Copy returns a copy of the StoreView

func (*StoreView) CreateAccount

func (sv *StoreView) CreateAccount(addr common.Address)

func (*StoreView) Delete

func (sv *StoreView) Delete(key common.Bytes)

Delete removes the value corresponding to the key

func (*StoreView) DeleteAccount

func (sv *StoreView) DeleteAccount(addr common.Address)

DeleteAccount deletes an account.

func (*StoreView) DeleteExpiredSplitRules

func (sv *StoreView) DeleteExpiredSplitRules(currentBlockHeight uint64) bool

DeleteExpiredSplitRules deletes a split rule.

func (*StoreView) DeleteSplitRule

func (sv *StoreView) DeleteSplitRule(resourceID string) bool

DeleteSplitRule deletes a split rule.

func (*StoreView) Empty

func (sv *StoreView) Empty(addr common.Address) bool

Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).

func (*StoreView) Exist

func (sv *StoreView) Exist(addr common.Address) bool

Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.

func (*StoreView) Get

func (sv *StoreView) Get(key common.Bytes) common.Bytes

Get returns the value corresponding to the key

func (*StoreView) GetAccount

func (sv *StoreView) GetAccount(addr common.Address) *types.Account

GetAccount returns an account.

func (*StoreView) GetBalance

func (sv *StoreView) GetBalance(addr common.Address) *big.Int

func (*StoreView) GetBlockHeight added in v1.0.0

func (sv *StoreView) GetBlockHeight() uint64

func (*StoreView) GetCode

func (sv *StoreView) GetCode(addr common.Address) []byte

func (*StoreView) GetCodeByHash

func (sv *StoreView) GetCodeByHash(codeHash common.Hash) []byte

func (*StoreView) GetCodeHash

func (sv *StoreView) GetCodeHash(addr common.Address) common.Hash

func (*StoreView) GetCodeSize

func (sv *StoreView) GetCodeSize(addr common.Address) int

func (*StoreView) GetCommittedState

func (sv *StoreView) GetCommittedState(addr common.Address, key common.Hash) common.Hash

func (*StoreView) GetDB

func (sv *StoreView) GetDB() database.Database

GetDB returns the underlying database.

func (*StoreView) GetDneroBalance

func (sv *StoreView) GetDneroBalance(addr common.Address) *big.Int

GetDneroBalance returns the DneroWei balance of the given address

func (*StoreView) GetDneroStake

func (sv *StoreView) GetDneroStake(addr common.Address) *big.Int

GetDneroStake returns the total amount of DneroWei the address staked to validators and/or sentrys

func (*StoreView) GetNonce

func (sv *StoreView) GetNonce(addr common.Address) uint64

func (*StoreView) GetOrCreateAccount

func (sv *StoreView) GetOrCreateAccount(addr common.Address) *types.Account

func (*StoreView) GetRefund

func (sv *StoreView) GetRefund() uint64

func (*StoreView) GetSentryCandidatePool added in v1.0.0

func (sv *StoreView) GetSentryCandidatePool() *core.SentryCandidatePool

GetGuradianCandidatePool gets the sentry candidate pool.

func (*StoreView) GetSlashIntents

func (sv *StoreView) GetSlashIntents() []types.SlashIntent

GetSlashIntents retrieves all the slashIntents

func (*StoreView) GetSplitRule

func (sv *StoreView) GetSplitRule(resourceID string) *types.SplitRule

GetSplitRule gets split rule.

func (*StoreView) GetStakeTransactionHeightList

func (sv *StoreView) GetStakeTransactionHeightList() *types.HeightList

GetStakeTransactionHeightList gets the heights of blocks that contain stake related transactions

func (*StoreView) GetState

func (sv *StoreView) GetState(addr common.Address, key common.Hash) common.Hash

func (*StoreView) GetStore

func (sv *StoreView) GetStore() *treestore.TreeStore

func (*StoreView) GetValidatorCandidatePool

func (sv *StoreView) GetValidatorCandidatePool() *core.ValidatorCandidatePool

GetValidatorCandidatePool gets the validator candidate pool.

func (*StoreView) HasSuicided

func (sv *StoreView) HasSuicided(addr common.Address) bool

func (*StoreView) Hash

func (sv *StoreView) Hash() common.Hash

Hash returns the root hash of the tree store

func (*StoreView) Height

func (sv *StoreView) Height() uint64

Height returns the block height corresponding to the stored state

func (*StoreView) IncrementHeight

func (sv *StoreView) IncrementHeight()

IncrementHeight increments the block height by 1

func (*StoreView) PopLogs

func (sv *StoreView) PopLogs() []*types.Log

func (*StoreView) ProveVCP

func (sv *StoreView) ProveVCP(vcpKey []byte, vp *core.VCPProof) error

func (*StoreView) Prune

func (sv *StoreView) Prune() error

func (*StoreView) ResetLogs

func (sv *StoreView) ResetLogs()

func (*StoreView) ResetRefund

func (sv *StoreView) ResetRefund()

func (*StoreView) RevertToSnapshot

func (sv *StoreView) RevertToSnapshot(root common.Hash)

func (*StoreView) Save

func (sv *StoreView) Save() common.Hash

Save saves the StoreView to the persistent storage, and return the root hash

func (*StoreView) Set

func (sv *StoreView) Set(key common.Bytes, value common.Bytes)

Set returns the value corresponding to the key

func (*StoreView) SetAccount

func (sv *StoreView) SetAccount(addr common.Address, acc *types.Account)

SetAccount sets an account.

func (*StoreView) SetCode

func (sv *StoreView) SetCode(addr common.Address, code []byte)

func (*StoreView) SetCoinbaseTransactionProcessed

func (sv *StoreView) SetCoinbaseTransactionProcessed(processed bool)

SetCoinbaseTransactionProcessed sets whether the coinbase transaction for the current block has been processed

func (*StoreView) SetNonce

func (sv *StoreView) SetNonce(addr common.Address, nonce uint64)

func (*StoreView) SetSplitRule

func (sv *StoreView) SetSplitRule(resourceID string, splitRule *types.SplitRule)

SetSplitRule sets split rule.

func (*StoreView) SetState

func (sv *StoreView) SetState(addr common.Address, key, val common.Hash)

func (*StoreView) Snapshot

func (sv *StoreView) Snapshot() common.Hash

func (*StoreView) SplitRuleExists

func (sv *StoreView) SplitRuleExists(resourceID string) bool

SplitRuleExists checks if a split rule associated with the given resourceID already exists

func (*StoreView) SubBalance

func (sv *StoreView) SubBalance(addr common.Address, amount *big.Int)

func (*StoreView) SubRefund

func (sv *StoreView) SubRefund(gas uint64)

func (*StoreView) Suicide

func (sv *StoreView) Suicide(addr common.Address) bool

func (*StoreView) UpdateSentryCandidatePool added in v1.0.0

func (sv *StoreView) UpdateSentryCandidatePool(gcp *core.SentryCandidatePool)

UpdateSentryCandidatePool updates the sentry candidate pool.

func (*StoreView) UpdateSplitRule

func (sv *StoreView) UpdateSplitRule(splitRule *types.SplitRule) bool

UpdateSplitRule updates a split rule

func (*StoreView) UpdateStakeTransactionHeightList

func (sv *StoreView) UpdateStakeTransactionHeightList(hl *types.HeightList)

UpdateStakeTransactionHeightList updates the heights of blocks that contain stake related transactions

func (*StoreView) UpdateValidatorCandidatePool

func (sv *StoreView) UpdateValidatorCandidatePool(vcp *core.ValidatorCandidatePool)

UpdateValidatorCandidatePool updates the validator candidate pool.

Jump to

Keyboard shortcuts

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