mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
get keys by maps.Keys
This commit is contained in:
parent
b6f2bbd417
commit
d294dd04d5
1 changed files with 3 additions and 8 deletions
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/trie/triestate"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
// State history records the state changes involved in executing a block. The
|
||||
|
|
@ -244,19 +245,13 @@ type history struct {
|
|||
// newHistory constructs the state history object with provided state change set.
|
||||
func newHistory(root common.Hash, parent common.Hash, block uint64, states *triestate.Set) *history {
|
||||
var (
|
||||
accountList []common.Address
|
||||
accountList = maps.Keys(states.Accounts)
|
||||
storageList = make(map[common.Address][]common.Hash)
|
||||
)
|
||||
for addr := range states.Accounts {
|
||||
accountList = append(accountList, addr)
|
||||
}
|
||||
slices.SortFunc(accountList, common.Address.Cmp)
|
||||
|
||||
for addr, slots := range states.Storages {
|
||||
slist := make([]common.Hash, 0, len(slots))
|
||||
for slotHash := range slots {
|
||||
slist = append(slist, slotHash)
|
||||
}
|
||||
slist := maps.Keys(slots)
|
||||
slices.SortFunc(slist, common.Hash.Cmp)
|
||||
storageList[addr] = slist
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue