forked from OpenAtomFoundation/xupercore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.go
30 lines (23 loc) · 882 Bytes
/
kernel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package contract
type KernRegistry interface {
RegisterKernMethod(contract, method string, handler KernMethod)
UnregisterKernMethod(ctract, method string)
// RegisterShortcut 用于contractName缺失的时候选择哪个合约名字和合约方法来执行对应的kernel合约
RegisterShortcut(oldmethod, contract, method string)
GetKernMethod(contract, method string) (KernMethod, error)
}
type KernMethod func(ctx KContext) (*Response, error)
type KContext interface {
// 交易相关数据
Args() map[string][]byte
Initiator() string
Caller() string
AuthRequire() []string
// 状态修改接口
StateSandbox
AddResourceUsed(delta Limits)
ResourceLimit() Limits
Call(module, contract, method string, args map[string][]byte) (*Response, error)
// 合约异步事件调用
EmitAsyncTask(event string, args interface{}) error
}