Skip to content

Commit

Permalink
fix accesslist in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Sep 9, 2024
1 parent 1b233e1 commit 2e667ad
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions core/state/access_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,36 @@ func (al *accessList) DeleteSlot(address common.Address, slot common.Hash) {
func (al *accessList) DeleteAddress(address common.Address) {
delete(al.addresses, address)
}

// Copy creates an independent copy of an accessList.
func (dest *accessList) Append(src *accessList) *accessList {
for addr, sIdx := range src.addresses {
if i, present := dest.addresses[addr]; present {
// dest already has addr.
if sIdx >= 0 {
// has slot in list
if i == -1 {
dest.addresses[addr] = len(dest.slots)
slotmap := src.slots[sIdx]
dest.slots = append(dest.slots, slotmap)
} else {
slotmap := src.slots[sIdx]
for hash := range slotmap {
if _, ok := dest.slots[i][hash]; !ok {
dest.slots[i][hash] = struct{}{}
}
}
}
}
} else {
// dest doesn't have the address
dest.addresses[addr] = -1
if sIdx >= 0 {
dest.addresses[addr] = len(dest.slots)
slotmap := src.slots[sIdx]
dest.slots = append(dest.slots, slotmap)
}
}
}
return dest
}

0 comments on commit 2e667ad

Please sign in to comment.