Documentation ¶
Index ¶
Constants ¶
const (
// DefaultBaseExecFee specifies default multiplier for opcode and syscall prices.
DefaultBaseExecFee = 30
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { Chain blockchainer.Blockchainer Container crypto.Verifiable Natives []Contract Trigger trigger.Type Block *block.Block Tx *transaction.Transaction DAO *dao.Cached Notifications []state.NotificationEvent Log *zap.Logger VM *vm.VM Functions [][]Function // contains filtered or unexported fields }
Context represents context in which interops are executed.
func NewContext ¶
func NewContext(trigger trigger.Type, bc blockchainer.Blockchainer, d dao.DAO, getContract func(dao.DAO, util.Uint160) (*state.Contract, error), natives []Contract, block *block.Block, tx *transaction.Transaction, log *zap.Logger) *Context
NewContext returns new interop context.
func (*Context) BaseExecFee ¶ added in v0.92.0
BaseExecFee represents factor to multiply syscall prices with.
func (*Context) GetContract ¶ added in v0.92.0
GetContract returns contract by its hash in current interop context.
func (*Context) GetFunction ¶ added in v0.91.0
GetFunction returns metadata for interop with the specified id.
type Contract ¶
type Contract interface { Initialize(*Context) error Metadata() *ContractMD OnPersist(*Context) error PostPersist(*Context) error }
Contract is an interface for all native contracts.
type ContractMD ¶
type ContractMD struct { Manifest manifest.Manifest Name string ContractID int32 Script []byte Hash util.Uint160 Methods map[string]MethodAndPrice }
ContractMD represents native contract instance.
func NewContractMD ¶
func NewContractMD(name string) *ContractMD
NewContractMD returns Contract with the specified list of methods.
func (*ContractMD) AddEvent ¶
func (c *ContractMD) AddEvent(name string, ps ...manifest.Parameter)
AddEvent adds new event to a native contract.
func (*ContractMD) AddMethod ¶
func (c *ContractMD) AddMethod(md *MethodAndPrice, desc *manifest.Method)
AddMethod adds new method to a native contract.
type Function ¶
type Function struct { ID uint32 Name string Func func(*Context) error // DisallowCallback is true iff syscall can't be used in a callback. DisallowCallback bool // ParamCount is a number of function parameters. ParamCount int Price int64 // RequiredFlags is a set of flags which must be set during script invocations. // Default value is NoneFlag i.e. no flags are required. RequiredFlags smartcontract.CallFlag }
Function binds function name, id with the function itself and price, it's supposed to be inited once for all interopContexts, so it doesn't use vm.InteropFuncPrice directly.
type MethodAndPrice ¶
type MethodAndPrice struct { Func Method MD *manifest.Method Price int64 RequiredFlags smartcontract.CallFlag }
MethodAndPrice is a native-contract method descriptor.