@@ -105,19 +105,6 @@ func (t *StateTrie) MustGet(key []byte) []byte {
105105 return t .trie .MustGet (crypto .Keccak256 (key ))
106106}
107107
108- // GetStorage attempts to retrieve a storage slot with provided account address
109- // and slot key. The value bytes must not be modified by the caller.
110- // If the specified storage slot is not in the trie, nil will be returned.
111- // If a trie node is not found in the database, a MissingNodeError is returned.
112- func (t * StateTrie ) GetStorage (_ common.Address , key []byte ) ([]byte , error ) {
113- enc , err := t .trie .Get (crypto .Keccak256 (key ))
114- if err != nil || len (enc ) == 0 {
115- return nil , err
116- }
117- _ , content , _ , err := rlp .Split (enc )
118- return content , err
119- }
120-
121108// GetAccount attempts to retrieve an account with provided account address.
122109// If the specified account is not in the trie, nil will be returned.
123110// If a trie node is not found in the database, a MissingNodeError is returned.
@@ -144,6 +131,39 @@ func (t *StateTrie) GetAccountByHash(addrHash common.Hash) (*types.StateAccount,
144131 return ret , err
145132}
146133
134+ // PrefetchAccount attempts to resolve specific accounts from the database
135+ // to accelerate subsequent trie operations.
136+ func (t * StateTrie ) PrefetchAccount (addresses []common.Address ) error {
137+ var keys [][]byte
138+ for _ , addr := range addresses {
139+ keys = append (keys , crypto .Keccak256 (addr .Bytes ()))
140+ }
141+ return t .trie .Prefetch (keys )
142+ }
143+
144+ // GetStorage attempts to retrieve a storage slot with provided account address
145+ // and slot key. The value bytes must not be modified by the caller.
146+ // If the specified storage slot is not in the trie, nil will be returned.
147+ // If a trie node is not found in the database, a MissingNodeError is returned.
148+ func (t * StateTrie ) GetStorage (_ common.Address , key []byte ) ([]byte , error ) {
149+ enc , err := t .trie .Get (crypto .Keccak256 (key ))
150+ if err != nil || len (enc ) == 0 {
151+ return nil , err
152+ }
153+ _ , content , _ , err := rlp .Split (enc )
154+ return content , err
155+ }
156+
157+ // PrefetchStorage attempts to resolve specific storage slots from the database
158+ // to accelerate subsequent trie operations.
159+ func (t * StateTrie ) PrefetchStorage (_ common.Address , keys [][]byte ) error {
160+ var keylist [][]byte
161+ for _ , key := range keys {
162+ keylist = append (keylist , crypto .Keccak256 (key ))
163+ }
164+ return t .trie .Prefetch (keylist )
165+ }
166+
147167// GetNode attempts to retrieve a trie node by compact-encoded path. It is not
148168// possible to use keybyte-encoding as the path might contain odd nibbles.
149169// If the specified trie node is not in the trie, nil will be returned.
0 commit comments