2020-01-20 12:31:12 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
2020-01-20 12:31:12 +00:00
|
|
|
)
|
|
|
|
|
2020-06-09 09:23:14 +00:00
|
|
|
// StoragePrice is a price for storing 1 byte of storage.
|
|
|
|
const StoragePrice = 100000
|
|
|
|
|
2020-01-20 12:31:12 +00:00
|
|
|
// getPrice returns a price for executing op with the provided parameter.
|
|
|
|
// Some SYSCALLs have variable price depending on their arguments.
|
2020-06-23 14:15:35 +00:00
|
|
|
func getPrice(v *vm.VM, op opcode.Opcode, parameter []byte) int64 {
|
2020-06-15 08:32:45 +00:00
|
|
|
if op == opcode.SYSCALL {
|
2020-01-20 12:31:12 +00:00
|
|
|
interopID := vm.GetInteropID(parameter)
|
2020-06-15 08:39:15 +00:00
|
|
|
ifunc := v.GetInteropByID(interopID)
|
|
|
|
if ifunc != nil && ifunc.Price > 0 {
|
2020-06-23 14:15:35 +00:00
|
|
|
return ifunc.Price
|
2020-06-15 08:39:15 +00:00
|
|
|
}
|
2020-01-20 12:31:12 +00:00
|
|
|
}
|
2020-06-15 08:32:45 +00:00
|
|
|
return opcodePrice(op)
|
2020-01-20 12:31:12 +00:00
|
|
|
}
|