Add refund support in JitVm

This commit is contained in:
Paweł Bylica 2015-01-21 19:37:41 +01:00
parent 91c0a80d34
commit 6a89bdc07a

View file

@ -207,6 +207,13 @@ func env_sstore(vmPtr unsafe.Pointer, indexPtr unsafe.Pointer, valuePtr unsafe.P
index := llvm2hash(bswap((*i256)(indexPtr))) index := llvm2hash(bswap((*i256)(indexPtr)))
value := llvm2hash(bswap((*i256)(valuePtr))) value := llvm2hash(bswap((*i256)(valuePtr)))
value = trim(value) value = trim(value)
if len(value) == 0 {
prevValue := vm.env.State().GetState(vm.me.Address(), index)
if len(prevValue) != 0 {
vm.Env().State().Refund(vm.callerAddr, GasSStoreRefund)
}
}
vm.env.State().SetState(vm.me.Address(), index, value) vm.env.State().SetState(vm.me.Address(), index, value)
} }