Documentation ¶
Index ¶
- Variables
- type Module
- func (s *Module) AddMPTBatch(index uint32, b mpt.Batch, cache *storage.MemCachedStore) (*mpt.Trie, *state.MPTRoot, error)
- func (s *Module) AddStateRoot(sr *state.MPTRoot) error
- func (s *Module) CleanStorage() error
- func (s *Module) CurrentLocalHeight() uint32
- func (s *Module) CurrentLocalStateRoot() util.Uint256
- func (s *Module) CurrentValidatedHeight() uint32
- func (s *Module) FindStates(root util.Uint256, prefix, start []byte, max int) ([]storage.KeyValue, error)
- func (s *Module) GC(index uint32, store storage.Store) time.Duration
- func (s *Module) GetLatestStateHeight(root util.Uint256) (uint32, error)
- func (s *Module) GetState(root util.Uint256, key []byte) ([]byte, error)
- func (s *Module) GetStateProof(root util.Uint256, key []byte) ([][]byte, error)
- func (s *Module) GetStateRoot(height uint32) (*state.MPTRoot, error)
- func (s *Module) GetStateValidators(height uint32) keys.PublicKeys
- func (s *Module) Init(height uint32) error
- func (s *Module) JumpToState(sr *state.MPTRoot)
- func (s *Module) ResetState(height uint32, cache *storage.MemCachedStore) error
- func (s *Module) SeekStates(root util.Uint256, prefix []byte, cont func(k, v []byte) bool)
- func (s *Module) SetUpdateValidatorsCallback(f func(uint32, keys.PublicKeys))
- func (s *Module) UpdateCurrentLocal(mpt *mpt.Trie, sr *state.MPTRoot)
- func (s *Module) UpdateStateValidators(height uint32, pubs keys.PublicKeys)
- func (s *Module) VerifyStateRoot(r *state.MPTRoot) error
- type VerifierFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStateMismatch means that local state root doesn't match the one // signed by state validators. ErrStateMismatch = errors.New("stateroot mismatch") )
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct { Store *storage.MemCachedStore // contains filtered or unexported fields }
Module represents module for local processing of state roots.
func NewModule ¶
func NewModule(cfg config.Blockchain, verif VerifierFunc, log *zap.Logger, s *storage.MemCachedStore) *Module
NewModule returns new instance of stateroot module.
func (*Module) AddMPTBatch ¶
func (s *Module) AddMPTBatch(index uint32, b mpt.Batch, cache *storage.MemCachedStore) (*mpt.Trie, *state.MPTRoot, error)
AddMPTBatch updates using provided batch.
func (*Module) AddStateRoot ¶
AddStateRoot adds validated state root provided by network.
func (*Module) CleanStorage ¶ added in v0.97.3
CleanStorage removes all MPT-related data from the storage (MPT nodes, validated stateroots) except local stateroot for the current height and GC flag. This method is aimed to clean outdated MPT data before state sync process can be started. Note: this method is aimed to be called for genesis block only, an error is returned otherwise.
func (*Module) CurrentLocalHeight ¶ added in v0.95.4
CurrentLocalHeight returns height of the local state root.
func (*Module) CurrentLocalStateRoot ¶
CurrentLocalStateRoot returns hash of the local state root.
func (*Module) CurrentValidatedHeight ¶
CurrentValidatedHeight returns current state root validated height.
func (*Module) FindStates ¶ added in v0.97.3
func (s *Module) FindStates(root util.Uint256, prefix, start []byte, max int) ([]storage.KeyValue, error)
FindStates returns a set of key-value pairs with keys matching the prefix starting from the `prefix`+`start` path from MPT with the specified root. `max` is the maximum number of elements to be returned. If nil `start` is specified, then the item with the key equal to the prefix is included into the result; if empty `start` is specified, then the item with the key equal to the prefix is not included into the result. In case there are no results (prefix is unused, start is after the last available element) mpt.ErrNotFound is returned.
func (*Module) GetLatestStateHeight ¶ added in v0.99.0
GetLatestStateHeight returns the latest blockchain height by the given stateroot.
func (*Module) GetState ¶ added in v0.97.3
GetState returns value at the specified key fom the MPT with the specified root.
func (*Module) GetStateProof ¶
GetStateProof returns proof of having key in the MPT with the specified root.
func (*Module) GetStateRoot ¶
GetStateRoot returns state root for a given height.
func (*Module) GetStateValidators ¶
func (s *Module) GetStateValidators(height uint32) keys.PublicKeys
GetStateValidators returns current state validators.
func (*Module) JumpToState ¶ added in v0.97.3
JumpToState performs jump to the state specified by given stateroot index.
func (*Module) ResetState ¶ added in v0.99.5
func (s *Module) ResetState(height uint32, cache *storage.MemCachedStore) error
ResetState resets MPT state to the given height.
func (*Module) SeekStates ¶ added in v0.102.0
SeekStates traverses over contract storage with the state based on the specified root. `prefix` is expected to consist of contract ID and the desired storage items prefix. `cont` is called for every matching key-value pair; the resulting key does not include contract ID and the desired storage item prefix (they are stripped to match the Blockchain's SeekStorage behaviour. The result includes item with the key that equals to the `prefix` (if such item is found in the storage). Traversal process is stopped when `false` is returned from `cont`.
func (*Module) SetUpdateValidatorsCallback ¶
func (s *Module) SetUpdateValidatorsCallback(f func(uint32, keys.PublicKeys))
SetUpdateValidatorsCallback sets callback for sending signed root.
func (*Module) UpdateCurrentLocal ¶ added in v0.94.1
UpdateCurrentLocal updates local caches using provided state root.
func (*Module) UpdateStateValidators ¶
func (s *Module) UpdateStateValidators(height uint32, pubs keys.PublicKeys)
UpdateStateValidators updates list of state validator keys.