kernel

package
v0.0.0-...-d9e9996 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "xkernel"

ModuleName moudle name

Variables

View Source
var (
	// ErrBlockChainExist is returned when create an existed block chain
	ErrBlockChainExist = errors.New("BlockChain Exist")
	// ErrCreateBlockChain is returned when create block chain error
	ErrCreateBlockChain = errors.New("Create BlockChain error")
	// ErrMethodNotImplemented is returned when calling a nonexisted kernel method
	ErrMethodNotImplemented = errors.New("Method not implemented")
	// ErrNoEnoughUTXO is returned when has no enough money to create new chain
	ErrNoEnoughUTXO = errors.New("No enough money to create new chain")
	// ErrAddrNotInWhiteList is returned when address not in whitelist
	ErrAddrNotInWhiteList = errors.New("Address not in white list")
	// ErrPermissionDenied is returned when has no permission to call contract
	ErrPermissionDenied = errors.New("Permission denied to call this contract")
	// ErrInvalidChainName is returned when chain name is invalid
	ErrInvalidChainName = errors.New("Invalid Chain name")
)

Functions

This section is empty.

Types

type AmperKernel

type AmperKernel struct {
	// contains filtered or unexported fields
}

AmperKernel define kernel contract method type

func NewKernel

func NewKernel(vmm *wasm.VMManager) (*AmperKernel, error)

NewKernel new an instance of AmperKernel, initialized with kernel contract method

func (*AmperKernel) GetName

func (xk *AmperKernel) GetName() string

GetName get moudle name

func (*AmperKernel) NewContext

func (xk *AmperKernel) NewContext(ctxCfg *contract.ContextConfig) (contract.Context, error)

NewContext new a context, initialized with KernelContext

type ChainRegister

type ChainRegister interface {
	RegisterBlockChain(name string) error
	UnloadBlockChain(name string) error
}

ChainRegister register blockchains

type DeployMethod

type DeployMethod struct {
	// contains filtered or unexported fields
}

DeployMethod define Deploy type

func (*DeployMethod) Invoke

func (dm *DeployMethod) Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)

Invoke Deploy contract method implementation

type GetMethod

type GetMethod struct {
}

GetMethod define Get type

func (*GetMethod) Invoke

func (gm *GetMethod) Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)

Invoke Get method implementation

type KContext

type KContext struct {
	ResourceLimit contract.Limits
	ModelCache    *xmodel.XMCache
	Initiator     string
	AuthRequire   []string
	ContextConfig *contract.ContextConfig
	// contains filtered or unexported fields
}

KContext define kernel contract context type

func (*KContext) AddResourceUsed

func (kc *KContext) AddResourceUsed(delta contract.Limits)

func (*KContext) AddXFeeUsed

func (kc *KContext) AddXFeeUsed(delta int64)

AddGasUsed set gas used when invoking kernel contract method

func (*KContext) Invoke

func (kc *KContext) Invoke(methodName string, args map[string][]byte) ([]byte, error)

Invoke entrance for kernel contract method invoke

func (*KContext) Release

func (kc *KContext) Release() error

Release release context

func (*KContext) ResourceUsed

func (kc *KContext) ResourceUsed() contract.Limits

type Kernel

type Kernel struct {
	// contains filtered or unexported fields
}

Kernel is the kernel contract

func (*Kernel) CreateBlockChain

func (k *Kernel) CreateBlockChain(name string, data []byte) error

CreateBlockChain create a new block chain from amper.json

func (*Kernel) Finalize

func (k *Kernel) Finalize(blockid []byte) error

Finalize implements ContractInterface

func (*Kernel) GetCryptoType

func (k *Kernel) GetCryptoType(data []byte) (string, error)

GetCryptoType get crypto type from amper.json

func (*Kernel) GetKVEngineType

func (k *Kernel) GetKVEngineType(data []byte) (string, error)

GetKVEngineType get kv engine type from amper.json

func (*Kernel) GetVATWhiteList

func (k *Kernel) GetVATWhiteList() map[string]bool

GetVATWhiteList 实现VAT接口

func (*Kernel) GetVerifiableAutogenTx

func (k *Kernel) GetVerifiableAutogenTx(blockHeight int64, maxCount int, timestamp int64) ([]*pb.Transaction, error)

GetVerifiableAutogenTx 实现VAT接口

func (*Kernel) Init

func (k *Kernel) Init(path string, log log.Logger, register ChainRegister, bcName string)

Init initialize kernel contract

func (*Kernel) ReadOutput

func (k *Kernel) ReadOutput(desc *contract.TxDesc) (contract.ContractOutputInterface, error)

ReadOutput implements ContractInterface

func (*Kernel) RemoveBlockChainData

func (k *Kernel) RemoveBlockChainData(name string) error

RemoveBlockChainData remove all the data associate to the named blockchain

func (*Kernel) Rollback

func (k *Kernel) Rollback(desc *contract.TxDesc) error

Rollback implements ContractInterface

func (*Kernel) Run

func (k *Kernel) Run(desc *contract.TxDesc) error

Run implements ContractInterface

func (*Kernel) SetContext

func (k *Kernel) SetContext(context *contract.TxContext) error

SetContext implements ContractInterface

func (*Kernel) SetMinNewChainAmount

func (k *Kernel) SetMinNewChainAmount(amount string)

SetMinNewChainAmount set the minimum amount of token to create a block chain

func (*Kernel) SetNewChainWhiteList

func (k *Kernel) SetNewChainWhiteList(whiteList map[string]bool)

SetNewChainWhiteList set the whitelit of address who can create new block chain

func (*Kernel) Stop

func (k *Kernel) Stop()

Stop implements ContractInterface

type Method

type Method interface {
	Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)
}

Method define method interface needed

type NewAccountMethod

type NewAccountMethod struct {
}

NewAccountMethod define NewAccountMethod type

func (*NewAccountMethod) Invoke

func (na *NewAccountMethod) Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)

Invoke NewAccount method implementation

type SetAccountACLMethod

type SetAccountACLMethod struct {
}

SetAccountACLMethod define SetAccountACLMethod type

func (*SetAccountACLMethod) Invoke

func (saa *SetAccountACLMethod) Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)

Invoke SetAccountACL method implementation

type SetMethod

type SetMethod struct {
}

SetMethod define Set type

func (*SetMethod) Invoke

func (sm *SetMethod) Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)

Invoke Set method implementation

type SetMethodACLMethod

type SetMethodACLMethod struct {
}

SetMethodACLMethod define SetMethodACLMethod type

func (*SetMethodACLMethod) Invoke

func (sma *SetMethodACLMethod) Invoke(ctx *KContext, args map[string][]byte) ([]byte, error)

Invoke SetMethodACL method implementation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL