Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"maps"
gomath "math"
"math/big"
"math/rand"
Expand Down Expand Up @@ -3128,9 +3129,7 @@ func testDeleteRecreateSlotsAcrossManyBlocks(t *testing.T, scheme string) {
var exp = new(expectation)
exp.blocknum = i + 1
exp.values = make(map[int]int)
for k, v := range current.values {
exp.values[k] = v
}
maps.Copy(exp.values, current.values)
exp.exist = current.exist

b.SetCoinbase(common.Address{1})
Expand Down
4 changes: 1 addition & 3 deletions core/state/snapshot/difflayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,7 @@ func (dl *diffLayer) flatten() snapshot {
if parent.stale.Swap(true) {
panic("parent diff layer is stale") // we've flattened into the same parent from two children, boo
}
for hash, data := range dl.accountData {
parent.accountData[hash] = data
}
maps.Copy(parent.accountData, dl.accountData)
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maps package import is missing from this file. Add 'import "maps"' to the import section to use maps.Copy.

Copilot uses AI. Check for mistakes.
// Overwrite all the updated storage slots (individually)
for accountHash, storage := range dl.storageData {
// If storage didn't exist (or was deleted) in the parent, overwrite blindly
Expand Down
9 changes: 3 additions & 6 deletions core/state/snapshot/difflayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package snapshot
import (
"bytes"
crand "crypto/rand"
"maps"
"math/rand"
"testing"

Expand All @@ -30,19 +31,15 @@ import (

func copyAccounts(accounts map[common.Hash][]byte) map[common.Hash][]byte {
copy := make(map[common.Hash][]byte)
for hash, blob := range accounts {
copy[hash] = blob
}
maps.Copy(copy, accounts)
return copy
}

func copyStorage(storage map[common.Hash]map[common.Hash][]byte) map[common.Hash]map[common.Hash][]byte {
copy := make(map[common.Hash]map[common.Hash][]byte)
for accHash, slots := range storage {
copy[accHash] = make(map[common.Hash][]byte)
for slotHash, blob := range slots {
copy[accHash][slotHash] = blob
}
maps.Copy(copy[accHash], slots)
}
return copy
}
Expand Down
13 changes: 4 additions & 9 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package txpool
import (
"errors"
"fmt"
"maps"
"math/big"
"sync"

Expand Down Expand Up @@ -385,9 +386,7 @@ func (p *TxPool) Add(txs []*types.Transaction, sync bool) []error {
func (p *TxPool) Pending(filter PendingFilter) map[common.Address][]*LazyTransaction {
txs := make(map[common.Address][]*LazyTransaction)
for _, subpool := range p.subpools {
for addr, set := range subpool.Pending(filter) {
txs[addr] = set
}
maps.Copy(txs, subpool.Pending(filter))
}
return txs
}
Expand Down Expand Up @@ -456,12 +455,8 @@ func (p *TxPool) Content() (map[common.Address][]*types.Transaction, map[common.
for _, subpool := range p.subpools {
run, block := subpool.Content()

for addr, txs := range run {
runnable[addr] = txs
}
for addr, txs := range block {
blocked[addr] = txs
}
maps.Copy(runnable, run)
maps.Copy(blocked, block)
}
return runnable, blocked
}
Expand Down