Update evm.go

This commit is contained in:
forkfury 2025-08-28 18:17:18 +02:00 committed by GitHub
parent 0979c6a1fa
commit dad41dac47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,11 +136,17 @@ func GetHashFn(ref *types.Header, chain ChainContext) func(n uint64) common.Hash
// CanTransfer checks whether there are enough funds in the address' account to make a transfer. // CanTransfer checks whether there are enough funds in the address' account to make a transfer.
// This does not take the necessary gas in to account to make the transfer valid. // This does not take the necessary gas in to account to make the transfer valid.
func CanTransfer(db vm.StateDB, addr common.Address, amount *uint256.Int) bool { func CanTransfer(db vm.StateDB, addr common.Address, amount *uint256.Int) bool {
if amount == nil {
return false
}
return db.GetBalance(addr).Cmp(amount) >= 0 return db.GetBalance(addr).Cmp(amount) >= 0
} }
// Transfer subtracts amount from sender and adds amount to recipient using the given Db // Transfer subtracts amount from sender and adds amount to recipient using the given Db
func Transfer(db vm.StateDB, sender, recipient common.Address, amount *uint256.Int) { func Transfer(db vm.StateDB, sender, recipient common.Address, amount *uint256.Int) {
if amount == nil {
return
}
db.SubBalance(sender, amount, tracing.BalanceChangeTransfer) db.SubBalance(sender, amount, tracing.BalanceChangeTransfer)
db.AddBalance(recipient, amount, tracing.BalanceChangeTransfer) db.AddBalance(recipient, amount, tracing.BalanceChangeTransfer)
} }