Documentation ¶
Index ¶
- Variables
- func ConvertTxToSDKTx(tx *AmpChainpb.Transaction) *pb.Transaction
- type Context
- type ContextManager
- type ContractError
- type Executor
- type Instance
- type SyscallService
- func (c *SyscallService) ContractCall(ctx context.Context, in *pb.ContractCallRequest) (*pb.ContractCallResponse, error)
- func (c *SyscallService) DeleteObject(ctx context.Context, in *pb.DeleteRequest) (*pb.DeleteResponse, error)
- func (c *SyscallService) GetCallArgs(ctx context.Context, in *pb.GetCallArgsRequest) (*pb.CallArgs, error)
- func (c *SyscallService) GetObject(ctx context.Context, in *pb.GetRequest) (*pb.GetResponse, error)
- func (c *SyscallService) NewIterator(ctx context.Context, in *pb.IteratorRequest) (*pb.IteratorResponse, error)
- func (c *SyscallService) Ping(ctx context.Context, in *pb.PingRequest) (*pb.PingResponse, error)
- func (c *SyscallService) PutObject(ctx context.Context, in *pb.PutRequest) (*pb.PutResponse, error)
- func (c *SyscallService) QueryBlock(ctx context.Context, in *pb.QueryBlockRequest) (*pb.QueryBlockResponse, error)
- func (c *SyscallService) QueryTx(ctx context.Context, in *pb.QueryTxRequest) (*pb.QueryTxResponse, error)
- func (c *SyscallService) SetOutput(ctx context.Context, in *pb.SetOutputRequest) (*pb.SetOutputResponse, error)
- func (c *SyscallService) Transfer(ctx context.Context, in *pb.TransferRequest) (*pb.TransferResponse, error)
- type XBridge
Constants ¶
This section is empty.
Variables ¶
var (
ErrOutOfDiskLimit = errors.New("out of disk limit")
)
Functions ¶
func ConvertTxToSDKTx ¶
func ConvertTxToSDKTx(tx *AmpChainpb.Transaction) *pb.Transaction
Types ¶
type Context ¶
type Context struct { ID int64 // 合约名字 ContractName string ResourceLimits contract.Limits Cache *xmodel.XMCache Args map[string][]byte Method string Initiator string AuthRequire []string // Write by contract Output *pb.Response }
Context 保存了合约执行的内核状态, 所有的系统调用产生的状态保存在这里
func (*Context) ExceedDiskLimit ¶
ExceedDiskLimit check whether disk usage exceeds limit
type ContextManager ¶
type ContextManager struct {
// contains filtered or unexported fields
}
ContextManager 用于管理产生和销毁Context
func NewContextManager ¶
func NewContextManager() *ContextManager
NewContextManager instances a new ContextManager
func (*ContextManager) Context ¶
func (n *ContextManager) Context(id int64) (*Context, bool)
Context 根据context的id返回当前运行当前合约的上下文
func (*ContextManager) DestroyContext ¶
func (n *ContextManager) DestroyContext(ctx *Context)
DestroyContext 一定要在合约执行完毕(成功或失败)进行销毁
func (*ContextManager) MakeContext ¶
func (n *ContextManager) MakeContext() *Context
MakeContext allocates a Context with unique context id
type ContractError ¶
ContractError indicates the error of the contract running result
func (*ContractError) Error ¶
func (c *ContractError) Error() string
Error implements error interface
type Executor ¶
type Executor interface { // RegisterSyscallService 用于虚拟机把系统调用链接到合约代码上,类似vdso // 注册到Registry的时候被调用一次 RegisterSyscallService(*SyscallService) // NewInstance 根据合约Context返回合约虚拟机的一个实例 NewInstance(ctx *Context) (Instance, error) }
Executor 为用户态虚拟机工厂类
type Instance ¶
type Instance interface { // Exec根据ctx里面的参数执行合约代码 Exec() error // ResourceUsed returns the resource used by contract ResourceUsed() contract.Limits // Release releases contract instance Release() }
Instance is an instance of a contract run
type SyscallService ¶
type SyscallService struct {
// contains filtered or unexported fields
}
SyscallService is the handler of contract syscalls
func NewSyscallService ¶
func NewSyscallService(ctxmgr *ContextManager) *SyscallService
NewSyscallService instances a new SyscallService
func (*SyscallService) ContractCall ¶
func (c *SyscallService) ContractCall(ctx context.Context, in *pb.ContractCallRequest) (*pb.ContractCallResponse, error)
ContractCall implements Syscall interface
func (*SyscallService) DeleteObject ¶
func (c *SyscallService) DeleteObject(ctx context.Context, in *pb.DeleteRequest) (*pb.DeleteResponse, error)
DeleteObject implements Syscall interface
func (*SyscallService) GetCallArgs ¶
func (c *SyscallService) GetCallArgs(ctx context.Context, in *pb.GetCallArgsRequest) (*pb.CallArgs, error)
GetCallArgs implements Syscall interface
func (*SyscallService) GetObject ¶
func (c *SyscallService) GetObject(ctx context.Context, in *pb.GetRequest) (*pb.GetResponse, error)
GetObject implements Syscall interface
func (*SyscallService) NewIterator ¶
func (c *SyscallService) NewIterator(ctx context.Context, in *pb.IteratorRequest) (*pb.IteratorResponse, error)
NewIterator implements Syscall interface
func (*SyscallService) Ping ¶
func (c *SyscallService) Ping(ctx context.Context, in *pb.PingRequest) (*pb.PingResponse, error)
Ping implements Syscall interface
func (*SyscallService) PutObject ¶
func (c *SyscallService) PutObject(ctx context.Context, in *pb.PutRequest) (*pb.PutResponse, error)
PutObject implements Syscall interface
func (*SyscallService) QueryBlock ¶
func (c *SyscallService) QueryBlock(ctx context.Context, in *pb.QueryBlockRequest) (*pb.QueryBlockResponse, error)
QueryBlock implements Syscall interface
func (*SyscallService) QueryTx ¶
func (c *SyscallService) QueryTx(ctx context.Context, in *pb.QueryTxRequest) (*pb.QueryTxResponse, error)
QueryTx implements Syscall interface
func (*SyscallService) SetOutput ¶
func (c *SyscallService) SetOutput(ctx context.Context, in *pb.SetOutputRequest) (*pb.SetOutputResponse, error)
SetOutput implements Syscall interface
func (*SyscallService) Transfer ¶
func (c *SyscallService) Transfer(ctx context.Context, in *pb.TransferRequest) (*pb.TransferResponse, error)
Transfer implements Syscall interface
type XBridge ¶
type XBridge struct {
// contains filtered or unexported fields
}
XBridge 用于注册用户虚拟机以及向AChain Core注册可被识别的vm.VirtualMachine
func (*XBridge) GetVirtualMachine ¶
func (v *XBridge) GetVirtualMachine(name string) (contract.VirtualMachine, bool)
GetVirtualMachine returns a contract.VirtualMachine from the given name
func (*XBridge) RegisterExecutor ¶
func (v *XBridge) RegisterExecutor(name string, exec Executor) contract.VirtualMachine
RegisterExecutor register a Executor to XBridge
func (*XBridge) RegisterToXCore ¶
func (v *XBridge) RegisterToXCore(regfunc func(name string, vm contract.VirtualMachine) error)
RegisterToXCore register VirtualMachines to AmpChain core