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
6 changes: 3 additions & 3 deletions action/protocol/execution/evm/access_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package evm

import (
"maps"

"github.com/ethereum/go-ethereum/common"
)

Expand Down Expand Up @@ -46,9 +48,7 @@ func newAccessList() *accessList {
// Copy creates an independent copy of an accessList.
func (al *accessList) Copy() *accessList {
cp := newAccessList()
for k, v := range al.addresses {
cp.addresses[k] = v
}
maps.Copy(cp.addresses, al.addresses)
cp.slots = make([]map[common.Hash]struct{}, len(al.slots))
for i, slotMap := range al.slots {
newSlotmap := make(map[common.Hash]struct{}, len(slotMap))
Expand Down
13 changes: 4 additions & 9 deletions action/protocol/execution/evm/evmstatedbadapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"encoding/hex"
"fmt"
"maps"
"math/big"
"sort"

Expand Down Expand Up @@ -800,9 +801,7 @@ func (stateDB *StateDBAdapter) Snapshot() int {
}
// save a copy of current SelfDestruct accounts
sa := make(deleteAccount)
for k, v := range stateDB.selfDestructed {
sa[k] = v
}
maps.Copy(sa, stateDB.selfDestructed)
stateDB.selfDestructedSnapshot[sn] = sa
if !stateDB.fixSnapshotOrder {
for _, addr := range stateDB.cachedContractAddrs() {
Expand All @@ -812,9 +811,7 @@ func (stateDB *StateDBAdapter) Snapshot() int {
stateDB.contractSnapshot[sn] = c
// save a copy of preimages
p := make(preimageMap)
for k, v := range stateDB.preimages {
p[k] = v
}
maps.Copy(p, stateDB.preimages)
stateDB.preimageSnapshot[sn] = p
// save a copy of access list
stateDB.accessListSnapshot[sn] = stateDB.accessList.Copy()
Expand All @@ -823,9 +820,7 @@ func (stateDB *StateDBAdapter) Snapshot() int {
stateDB.transientStorageSnapshot[sn] = stateDB.transientStorage.Copy()
// save a copy of created account map
ca := make(createdAccount)
for k, v := range stateDB.createdAccount {
ca[k] = v
}
maps.Copy(ca, stateDB.createdAccount)
stateDB.createdAccountSnapshot[sn] = ca
}
return sn
Expand Down
9 changes: 3 additions & 6 deletions blockindex/contractstaking/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package contractstaking
import (
"context"
"log"
"maps"
"math/big"
"sync"

Expand Down Expand Up @@ -289,9 +290,7 @@ func (s *contractStakingCache) Clone() stakingCache {
c.candidateBucketMap = make(map[string]map[uint64]bool, len(s.candidateBucketMap))
for k, v := range s.candidateBucketMap {
c.candidateBucketMap[k] = make(map[uint64]bool, len(v))
for k1, v1 := range v {
c.candidateBucketMap[k][k1] = v1
}
maps.Copy(c.candidateBucketMap[k], v)
}
c.bucketTypeMap = make(map[uint64]*BucketType, len(s.bucketTypeMap))
for k, v := range s.bucketTypeMap {
Expand All @@ -300,9 +299,7 @@ func (s *contractStakingCache) Clone() stakingCache {
c.propertyBucketTypeMap = make(map[int64]map[uint64]uint64, len(s.propertyBucketTypeMap))
for k, v := range s.propertyBucketTypeMap {
c.propertyBucketTypeMap[k] = make(map[uint64]uint64, len(v))
for k1, v1 := range v {
c.propertyBucketTypeMap[k][k1] = v1
}
maps.Copy(c.propertyBucketTypeMap[k], v)
}
c.deltaBucketTypes = make(map[uint64]*BucketType, len(s.deltaBucketTypes))
for k, v := range s.deltaBucketTypes {
Expand Down
5 changes: 2 additions & 3 deletions blockindex/contractstaking/wrappedcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package contractstaking

import (
"context"
"maps"
"math/big"
"sort"
"sync"
Expand Down Expand Up @@ -271,9 +272,7 @@ func (wc *wrappedCache) Clone() stakingCache {
updatedCandidates := make(map[string]map[uint64]bool, len(wc.updatedCandidates))
for delegate, buckets := range wc.updatedCandidates {
updatedBuckets := make(map[uint64]bool, len(buckets))
for id, updated := range buckets {
updatedBuckets[id] = updated
}
maps.Copy(updatedBuckets, buckets)
updatedCandidates[delegate] = updatedBuckets
}
return &wrappedCache{
Expand Down
5 changes: 2 additions & 3 deletions dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package dispatcher

import (
"context"
"maps"
"sync"
"time"

Expand Down Expand Up @@ -186,9 +187,7 @@ func (d *IotxDispatcher) EventAudit() map[iotexrpc.MessageType]int {
d.eventAuditLock.RLock()
defer d.eventAuditLock.RUnlock()
snapshot := make(map[iotexrpc.MessageType]int)
for k, v := range d.eventAudit {
snapshot[k] = v
}
maps.Copy(snapshot, d.eventAudit)
return snapshot
}

Expand Down