diff --git a/trie/transition.go b/trie/transition.go index ad3f782b75..1670b8e793 100644 --- a/trie/transition.go +++ b/trie/transition.go @@ -78,6 +78,17 @@ func (t *TransitionTrie) GetStorage(addr common.Address, key []byte) ([]byte, er return t.base.GetStorage(addr, key) } +// PrefetchStorage attempts to resolve specific storage slots from the database +// to accelerate subsequent trie operations. +func (t *TransitionTrie) PrefetchStorage(addr common.Address, keys [][]byte) error { + for _, key := range keys { + if _, err := t.GetStorage(addr, key); err != nil { + return err + } + } + return nil +} + // GetAccount abstract an account read from the trie. func (t *TransitionTrie) GetAccount(address common.Address) (*types.StateAccount, error) { data, err := t.overlay.GetAccount(address) @@ -94,6 +105,17 @@ func (t *TransitionTrie) GetAccount(address common.Address) (*types.StateAccount return t.base.GetAccount(address) } +// PrefetchAccount attempts to resolve specific accounts from the database +// to accelerate subsequent trie operations. +func (t *TransitionTrie) PrefetchAccount(addresses []common.Address) error { + for _, addr := range addresses { + if _, err := t.GetAccount(addr); err != nil { + return err + } + } + return nil +} + // UpdateStorage associates key with value in the trie. If value has length zero, any // existing value is deleted from the trie. The value bytes must not be modified // by the caller while they are stored in the trie. @@ -173,7 +195,7 @@ func (t *TransitionTrie) IsVerkle() bool { return true } -// UpdateStems updates a group of values, given the stem they are using. If +// UpdateStem updates a group of values, given the stem they are using. If // a value already exists, it is overwritten. func (t *TransitionTrie) UpdateStem(key []byte, values [][]byte) error { trie := t.overlay