This commit is contained in:
Jared Wasinger 2025-10-27 14:07:14 +08:00
parent a868a8e1e0
commit 5b4d7cc2e2
4 changed files with 8 additions and 2 deletions

View file

@ -577,7 +577,8 @@ func (s *StateDB) updateStateObject(obj *stateObject) {
} }
} }
// updateStateObject writes the given object to the trie. // updateStateObject writes the given object to the trie. The actual value is
// only resolved from the provided function when it is needed during trie hashing.
func (s *StateDB) updateStateObjectAsync(addr common.Address, resolver func() *types.StateAccount) { func (s *StateDB) updateStateObjectAsync(addr common.Address, resolver func() *types.StateAccount) {
if err := s.trie.UpdateAccountAsync(addr, resolver); err != nil { if err := s.trie.UpdateAccountAsync(addr, resolver); err != nil {
s.setError(fmt.Errorf("updateStateObject (%x) error: %v", addr, err)) s.setError(fmt.Errorf("updateStateObject (%x) error: %v", addr, err))

@ -1 +1 @@
Subproject commit 81862e4848585a438d64f911a19b3825f0f4cd95 Subproject commit c67e485ff8b5be9abc8ad15345ec21aa22e290d9

View file

@ -226,6 +226,9 @@ func (t *StateTrie) UpdateAccount(address common.Address, acc *types.StateAccoun
return nil return nil
} }
// UpdateAccountAsync will abstract the write of an account to the secure trie.
// The actual value of the account is not resolved from the passed function until
// it is needed when hashing the trie.
func (t *StateTrie) UpdateAccountAsync(address common.Address, accountResolve func() *types.StateAccount) error { func (t *StateTrie) UpdateAccountAsync(address common.Address, accountResolve func() *types.StateAccount) error {
hk := crypto.Keccak256(address.Bytes()) hk := crypto.Keccak256(address.Bytes())
resolve := func() []byte { resolve := func() []byte {

View file

@ -382,6 +382,8 @@ func (t *Trie) Update(key, value []byte) error {
return t.update(key, value) return t.update(key, value)
} }
// UpdateAsync associates a key with value in the trie. The actual value is
// not resolved until needed (by calling Get, or Hash).
func (t *Trie) UpdateAsync(key []byte, valueResolver func() []byte) error { func (t *Trie) UpdateAsync(key []byte, valueResolver func() []byte) error {
t.unhashed++ t.unhashed++
t.uncommitted++ t.uncommitted++