Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteClass(w db.KeyValueWriter, classHash *felt.Felt) error
- func DeleteClassHashHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64) error
- func DeleteContract(w db.KeyValueWriter, addr *felt.Felt) error
- func DeleteNonceHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64) error
- func DeleteStorageHistory(w db.KeyValueWriter, addr, key *felt.Felt, blockNum uint64) error
- func GetClass(r db.KeyValueReader, classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
- func GetContract(r db.KeyValueReader, addr *felt.Felt) (stateContract, error)
- func GetStateObject(r db.KeyValueReader, state *State, addr *felt.Felt) (*stateObject, error)
- func HasClass(r db.KeyValueReader, classHash *felt.Felt) (bool, error)
- func HasContract(r db.KeyValueReader, addr *felt.Felt) (bool, error)
- func WriteClass(w db.KeyValueWriter, classHash *felt.Felt, class core.ClassDefinition, ...) error
- func WriteClassHashHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64, classHash *felt.Felt) error
- func WriteContract(w db.KeyValueWriter, addr *felt.Felt, contract *stateContract) error
- func WriteNonceHistory(w db.KeyValueWriter, addr *felt.Felt, blockNum uint64, nonce *felt.Felt) error
- func WriteStorageHistory(w db.KeyValueWriter, addr, key *felt.Felt, blockNum uint64, value *felt.Felt) error
- type ClassReader
- type ContractReader
- type State
- func (s *State) Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
- func (s *State) ClassTrie() (*trie2.Trie, error)
- func (s *State) Commitment() (felt.Felt, error)
- func (s *State) ContractClassHash(addr *felt.Felt) (felt.Felt, error)
- func (s *State) ContractClassHashAt(addr *felt.Felt, blockNum uint64) (felt.Felt, error)
- func (s *State) ContractDeployedAt(addr *felt.Felt, blockNum uint64) (bool, error)
- func (s *State) ContractNonce(addr *felt.Felt) (felt.Felt, error)
- func (s *State) ContractNonceAt(addr *felt.Felt, blockNum uint64) (felt.Felt, error)
- func (s *State) ContractStorage(addr, key *felt.Felt) (felt.Felt, error)
- func (s *State) ContractStorageAt(addr, key *felt.Felt, blockNum uint64) (felt.Felt, error)
- func (s *State) ContractStorageTrie(addr *felt.Felt) (*trie2.Trie, error)
- func (s *State) ContractTrie() (*trie2.Trie, error)
- func (s *State) GetReverseStateDiff(blockNum uint64, diff *core.StateDiff) (core.StateDiff, error)
- func (s *State) Revert(blockNum uint64, update *core.StateUpdate) error
- func (s *State) Update(blockNum uint64, update *core.StateUpdate, ...) error
- type StateDB
- type StateHistory
- func (s *StateHistory) Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
- func (s *StateHistory) ClassTrie() (*trie2.Trie, error)
- func (s *StateHistory) ContractClassHash(addr *felt.Felt) (felt.Felt, error)
- func (s *StateHistory) ContractNonce(addr *felt.Felt) (felt.Felt, error)
- func (s *StateHistory) ContractStorage(addr, key *felt.Felt) (felt.Felt, error)
- func (s *StateHistory) ContractStorageTrie(addr *felt.Felt) (*trie2.Trie, error)
- func (s *StateHistory) ContractTrie() (*trie2.Trie, error)
- type StateReader
- type Storage
- type TrieProvider
Constants ¶
const ( ClassTrieHeight = 251 ContractTrieHeight = 251 ContractStorageTrieHeight = 251 )
const DefaultMaxLayers = 128
DefaultMaxLayers is the default maximum number of layers to keep in the cache
Variables ¶
Functions ¶
func DeleteClass ¶
func DeleteClass(w db.KeyValueWriter, classHash *felt.Felt) error
func DeleteClassHashHistory ¶
func DeleteContract ¶
func DeleteContract(w db.KeyValueWriter, addr *felt.Felt) error
func DeleteNonceHistory ¶
func DeleteStorageHistory ¶
func GetClass ¶
func GetClass(r db.KeyValueReader, classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
func GetContract ¶
func GetContract(r db.KeyValueReader, addr *felt.Felt) (stateContract, error)
Gets a contract instance from the database. If it doesn't exist returns a contract not deployed error
func GetStateObject ¶
func HasContract ¶
func WriteClass ¶
func WriteClass( w db.KeyValueWriter, classHash *felt.Felt, class core.ClassDefinition, declaredAt uint64, ) error
func WriteClassHashHistory ¶
func WriteContract ¶
func WriteContract(w db.KeyValueWriter, addr *felt.Felt, contract *stateContract) error
func WriteNonceHistory ¶
func WriteStorageHistory ¶
Types ¶
type ClassReader ¶
type ClassReader interface {
Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
}
type ContractReader ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) Commitment ¶
Returns the state commitment
func (*State) ContractClassHash ¶
func (*State) ContractClassHashAt ¶
Returns the class hash of a contract at a given block number.
func (*State) ContractDeployedAt ¶
func (*State) ContractNonceAt ¶
Returns the nonce of a contract at a given block number.
func (*State) ContractStorage ¶
func (*State) ContractStorageAt ¶
Returns the storage value of a contract at a given storage key at a given block number.
func (*State) ContractStorageTrie ¶
func (*State) GetReverseStateDiff ¶
func (*State) Revert ¶
func (s *State) Revert(blockNum uint64, update *core.StateUpdate) error
Revert a given state update. The block number is the block number of the state update.
func (*State) Update ¶
func (s *State) Update( blockNum uint64, update *core.StateUpdate, declaredClasses map[felt.Felt]core.ClassDefinition, ) error
Applies a state update to a given state. If any error is encountered, state is not updated. After a state update is applied, the root of the state must match the given new root in the state update. TODO(weiihann): deal with flush atomicity
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func NewStateDB ¶
func NewStateDB(disk db.KeyValueStore, triedb *triedb.Database) *StateDB
func (*StateDB) ContractStorageTrie ¶
Opens a contract storage trie for the given state root and contract address
type StateHistory ¶
type StateHistory struct {
// contains filtered or unexported fields
}
StateHistory represents a snapshot of the blockchain state at a specific block number.
func NewStateHistory ¶
func (*StateHistory) Class ¶
func (s *StateHistory) Class(classHash *felt.Felt) (*core.DeclaredClassDefinition, error)
func (*StateHistory) ContractClassHash ¶
func (*StateHistory) ContractNonce ¶
func (*StateHistory) ContractStorage ¶
func (*StateHistory) ContractStorageTrie ¶
func (*StateHistory) ContractTrie ¶
func (s *StateHistory) ContractTrie() (*trie2.Trie, error)
type StateReader ¶
type StateReader interface {
ContractReader
ClassReader
TrieProvider
}