stateroot: fix spelling and enhance FindStates doc, fix #2925

This commit is contained in:
Roman Khimov 2023-03-15 22:55:19 +03:00
parent a8aa29727b
commit 44e84a5943

View file

@ -80,11 +80,13 @@ func (s *Module) GetState(root util.Uint256, key []byte) ([]byte, error) {
return tr.Get(key) return tr.Get(key)
} }
// FindStates returns set of key-value pairs with key matching the prefix starting // FindStates returns a set of key-value pairs with keys matching the prefix starting
// from the `prefix`+`start` path from MPT trie with the specified root. `max` is // from the `prefix`+`start` path from MPT with the specified root. `max` is
// the maximum number of elements to be returned. If nil `start` specified, then // the maximum number of elements to be returned. If nil `start` is specified, then the
// item with key equals to prefix is included into result; if empty `start` specified, // item with the key equal to the prefix is included into the result; if empty `start` is specified,
// then item with key equals to prefix is not included into result. // 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 (s *Module) FindStates(root util.Uint256, prefix, start []byte, max int) ([]storage.KeyValue, error) { func (s *Module) FindStates(root util.Uint256, prefix, start []byte, max int) ([]storage.KeyValue, error) {
// Allow accessing old values, it's RO thing. // Allow accessing old values, it's RO thing.
tr := mpt.NewTrie(mpt.NewHashNode(root), s.mode&^mpt.ModeGCFlag, storage.NewMemCachedStore(s.Store)) tr := mpt.NewTrie(mpt.NewHashNode(root), s.mode&^mpt.ModeGCFlag, storage.NewMemCachedStore(s.Store))