mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Apply suggestions from code review
Co-authored-by: Martin HS <martin@swende.se>
This commit is contained in:
parent
37952f6063
commit
dbca8bb5d4
1 changed files with 9 additions and 9 deletions
|
|
@ -81,11 +81,10 @@ func (ae *AccessEvents) Keys() [][]byte {
|
||||||
|
|
||||||
func (ae *AccessEvents) Copy() *AccessEvents {
|
func (ae *AccessEvents) Copy() *AccessEvents {
|
||||||
cpy := &AccessEvents{
|
cpy := &AccessEvents{
|
||||||
branches: make(map[branchAccessKey]mode),
|
branches: maps.Clone(ae.branches),
|
||||||
chunks: make(map[chunkAccessKey]mode),
|
chunks: maps.Clone(ae.chunks),
|
||||||
pointCache: ae.pointCache,
|
pointCache: ae.pointCache,
|
||||||
}
|
}
|
||||||
cpy.Merge(ae)
|
|
||||||
return cpy
|
return cpy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,9 +92,11 @@ func (ae *AccessEvents) Copy() *AccessEvents {
|
||||||
// member fields of an account.
|
// member fields of an account.
|
||||||
func (ae *AccessEvents) AddAccount(addr []byte, isWrite bool) uint64 {
|
func (ae *AccessEvents) AddAccount(addr []byte, isWrite bool) uint64 {
|
||||||
var gas uint64
|
var gas uint64
|
||||||
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
|
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, VersionLeafKey, isWrite)
|
||||||
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, byte(i), isWrite)
|
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, BalanceLeafKey, isWrite)
|
||||||
}
|
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, NonceLeafKey, isWrite)
|
||||||
|
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, CodeKeccakLeafKey, isWrite)
|
||||||
|
gas += ae.touchAddressAndChargeGas(addr, zeroTreeIndex, CodeSizeLeafKey, isWrite)
|
||||||
return gas
|
return gas
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -268,9 +269,8 @@ func (ae *AccessEvents) CodeChunksRangeGas(contractAddr []byte, startPC, size ui
|
||||||
return statelessGasCharged
|
return statelessGasCharged
|
||||||
}
|
}
|
||||||
|
|
||||||
// VersionGas returns the amount of gas to be charged if the account's version hasn't been
|
// VersionGas adds the accounts version to the accessed data, and returns the
|
||||||
// touched in the proper mode. If `isWrite` is `true` then the charged gas is for an access
|
// amount of gas that it costs.
|
||||||
// in write mode. If false, the charged gas corresponds to an access in read mode.
|
|
||||||
// Note that an access in write mode implies an access in read mode, whereas an access in
|
// Note that an access in write mode implies an access in read mode, whereas an access in
|
||||||
// read mode does not imply an access in write mode.
|
// read mode does not imply an access in write mode.
|
||||||
func (ae *AccessEvents) VersionGas(addr []byte, isWrite bool) uint64 {
|
func (ae *AccessEvents) VersionGas(addr []byte, isWrite bool) uint64 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue