forked from TrueCloudLab/neoneo-go
core: calculate opcode prices correctly
This commit is contained in:
parent
8f20a70969
commit
fd2cd291e7
1 changed files with 2 additions and 9 deletions
|
@ -17,21 +17,14 @@ const StoragePrice = 100000
|
||||||
// getPrice returns a price for executing op with the provided parameter.
|
// getPrice returns a price for executing op with the provided parameter.
|
||||||
// Some SYSCALLs have variable price depending on their arguments.
|
// Some SYSCALLs have variable price depending on their arguments.
|
||||||
func getPrice(v *vm.VM, op opcode.Opcode, parameter []byte) util.Fixed8 {
|
func getPrice(v *vm.VM, op opcode.Opcode, parameter []byte) util.Fixed8 {
|
||||||
if op <= opcode.NOP {
|
if op == opcode.SYSCALL {
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
switch op {
|
|
||||||
case opcode.SYSCALL:
|
|
||||||
interopID := vm.GetInteropID(parameter)
|
interopID := vm.GetInteropID(parameter)
|
||||||
ifunc := v.GetInteropByID(interopID)
|
ifunc := v.GetInteropByID(interopID)
|
||||||
if ifunc != nil && ifunc.Price > 0 {
|
if ifunc != nil && ifunc.Price > 0 {
|
||||||
return toFixed8(int64(ifunc.Price))
|
return toFixed8(int64(ifunc.Price))
|
||||||
}
|
}
|
||||||
return toFixed8(1)
|
|
||||||
default:
|
|
||||||
return toFixed8(1)
|
|
||||||
}
|
}
|
||||||
|
return opcodePrice(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toFixed8(n int64) util.Fixed8 {
|
func toFixed8(n int64) util.Fixed8 {
|
||||||
|
|
Loading…
Reference in a new issue