neo-go/pkg/core/gas_price.go
Evgenii Stratonikov 61bba1a39c core: store precise gas price in interop descriptions
In NEO3 sycalls can have prices less than 10^5, we need to store them
precisely. Adjusting actual prices is to be done in the following tasks.
2020-06-15 12:02:28 +03:00

23 lines
666 B
Go

package core
import (
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
)
// StoragePrice is a price for storing 1 byte of storage.
const StoragePrice = 100000
// getPrice returns a price for executing op with the provided parameter.
// Some SYSCALLs have variable price depending on their arguments.
func getPrice(v *vm.VM, op opcode.Opcode, parameter []byte) util.Fixed8 {
if op == opcode.SYSCALL {
interopID := vm.GetInteropID(parameter)
ifunc := v.GetInteropByID(interopID)
if ifunc != nil && ifunc.Price > 0 {
return util.Fixed8(ifunc.Price)
}
}
return opcodePrice(op)
}