Skip to content

Commit

Permalink
refactor(state): simplify key retrieval in TouchedAccounts using maps…
Browse files Browse the repository at this point in the history
….Keys
  • Loading branch information
johntaiko committed Jan 22, 2025
1 parent 1e9e5df commit 477f04a
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions core/state/taiko_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@ package state

import (
"github.com/ethereum/go-ethereum/common"
"golang.org/x/exp/maps"
)

func (s Storage) Keys() []common.Hash {
keys := make([]common.Hash, 0, len(s))
for key := range s {
keys = append(keys, key)
}
return keys
}

// TouchedAccounts represents the storage of an account at a specific point in time.
type TouchedAccounts map[common.Address][]common.Hash

Expand All @@ -20,12 +13,12 @@ type TouchedAccounts map[common.Address][]common.Hash
func (s *StateDB) TouchedAccounts() TouchedAccounts {
touched := make(TouchedAccounts, len(s.stateObjects))
for addr, obj := range s.stateObjects {
touched[addr] = obj.originStorage.Keys()
touched[addr] = maps.Keys(obj.originStorage)
}
for addr, obj := range s.stateObjectsDestruct {
// ignore empty account because it won't affect the state
if !obj.empty() {
touched[addr] = obj.originStorage.Keys()
touched[addr] = maps.Keys(obj.originStorage)
}
}
return touched
Expand Down

0 comments on commit 477f04a

Please sign in to comment.