mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-11 15:30:07 +00:00
61bba1a39c
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.
23 lines
666 B
Go
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)
|
|
}
|