mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-22 15:59:26 +00:00
core/state: improve PrettyPrint function (#32293)
This commit is contained in:
parent
a56558d092
commit
d14d4d2af0
2 changed files with 5 additions and 13 deletions
|
|
@ -145,10 +145,7 @@ func (al *accessList) Equal(other *accessList) bool {
|
||||||
// PrettyPrint prints the contents of the access list in a human-readable form
|
// PrettyPrint prints the contents of the access list in a human-readable form
|
||||||
func (al *accessList) PrettyPrint() string {
|
func (al *accessList) PrettyPrint() string {
|
||||||
out := new(strings.Builder)
|
out := new(strings.Builder)
|
||||||
var sortedAddrs []common.Address
|
sortedAddrs := slices.Collect(maps.Keys(al.addresses))
|
||||||
for addr := range al.addresses {
|
|
||||||
sortedAddrs = append(sortedAddrs, addr)
|
|
||||||
}
|
|
||||||
slices.SortFunc(sortedAddrs, common.Address.Cmp)
|
slices.SortFunc(sortedAddrs, common.Address.Cmp)
|
||||||
for _, addr := range sortedAddrs {
|
for _, addr := range sortedAddrs {
|
||||||
idx := al.addresses[addr]
|
idx := al.addresses[addr]
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -70,19 +71,13 @@ func (t transientStorage) Copy() transientStorage {
|
||||||
// PrettyPrint prints the contents of the access list in a human-readable form
|
// PrettyPrint prints the contents of the access list in a human-readable form
|
||||||
func (t transientStorage) PrettyPrint() string {
|
func (t transientStorage) PrettyPrint() string {
|
||||||
out := new(strings.Builder)
|
out := new(strings.Builder)
|
||||||
var sortedAddrs []common.Address
|
sortedAddrs := slices.Collect(maps.Keys(t))
|
||||||
for addr := range t {
|
slices.SortFunc(sortedAddrs, common.Address.Cmp)
|
||||||
sortedAddrs = append(sortedAddrs, addr)
|
|
||||||
slices.SortFunc(sortedAddrs, common.Address.Cmp)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, addr := range sortedAddrs {
|
for _, addr := range sortedAddrs {
|
||||||
fmt.Fprintf(out, "%#x:", addr)
|
fmt.Fprintf(out, "%#x:", addr)
|
||||||
var sortedKeys []common.Hash
|
|
||||||
storage := t[addr]
|
storage := t[addr]
|
||||||
for key := range storage {
|
sortedKeys := slices.Collect(maps.Keys(storage))
|
||||||
sortedKeys = append(sortedKeys, key)
|
|
||||||
}
|
|
||||||
slices.SortFunc(sortedKeys, common.Hash.Cmp)
|
slices.SortFunc(sortedKeys, common.Hash.Cmp)
|
||||||
for _, key := range sortedKeys {
|
for _, key := range sortedKeys {
|
||||||
fmt.Fprintf(out, " %X : %X\n", key, storage[key])
|
fmt.Fprintf(out, " %X : %X\n", key, storage[key])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue