common

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGas = uint64(100000)

DefaultGas 默认的Gas值

Variables

View Source
var (
	// ErrContractIdIsNil err msg
	ErrContractIdIsNil = errors.New("the contractId is empty")
	// ErrContractNotFound err msg
	ErrContractNotFound = errors.New("the contractName is not exist")
	// ErrTxTypeNotSupport err msg
	ErrTxTypeNotSupport = errors.New("the txType does not support")
	// ErrMethodNotFound err msg
	ErrMethodNotFound = errors.New("the method does not found")
	// ErrParamsEmpty err msg
	ErrParamsEmpty = errors.New("the params is empty")
	// ErrContractName err msg
	ErrContractName = errors.New("the contractName is error")
	// ErrOutOfRange err msg
	ErrOutOfRange = errors.New("out of range")
	// ErrParams err msg
	ErrParams = errors.New("params is error")
	// ErrSequence err msg
	ErrSequence = errors.New("sequence is error")
	// ErrUnmarshalFailed err msg
	ErrUnmarshalFailed = errors.New("unmarshal is error")
)

Functions

func GetChainConfig added in v2.3.0

func GetChainConfig(txSimContext protocol.TxSimContext) (*configPb.ChainConfig, error)

GetChainConfig 获得当前的链配置,记入读集 @param txSimContext @return *configPb.ChainConfig @return error

func GetChainConfigNoRecord added in v2.3.0

func GetChainConfigNoRecord(txSimContext protocol.TxSimContext) (*configPb.ChainConfig, error)

GetChainConfigNoRecord 获得当前的链配置,不记入读集 @param txSimContext @return *configPb.ChainConfig @return error

func GetGas added in v2.2.0

func GetGas(contractName, method string, defaultGas uint64) uint64

GetGas 获得一个系统合约的某个方法的Gas值,如果没有配置,则返回默认的Gas值

func ResultBytesAndError added in v2.2.0

func ResultBytesAndError(returnResult []byte, event []*common.ContractEvent, err error) *common.ContractResult

ResultBytesAndError make *common.ContractResult with data,err

func ResultError added in v2.2.0

func ResultError(err error) *common.ContractResult

ResultError make *common.ContractResult with err

func ResultErrorWithGasUsed added in v2.2.0

func ResultErrorWithGasUsed(err error, gas uint64) *common.ContractResult

ResultErrorWithGasUsed 构造一个包含Error结果的ContractResult对象 @param err @param gas @return *common.ContractResult

func ResultJson added in v2.2.0

func ResultJson(obj interface{}) (*common.ContractResult, error)

ResultJson 构造一个包含输入对象Json作为Result的ContractResult对象 @param obj @return *common.ContractResult @return error

func ResultSuccess added in v2.2.0

func ResultSuccess(result []byte, gas uint64) *common.ContractResult

ResultSuccess make *common.ContractResult with data

func WrapEventResult added in v2.3.0

func WrapEventResult(f func(txSimContext protocol.TxSimContext, parameters map[string][]byte) (
	[]byte, []*common.ContractEvent, error)) func(
	txSimContext protocol.TxSimContext, parameters map[string][]byte) *common.ContractResult

WrapEventResult 包装原有的返回[]byte的函数,改为返回ContractResult和事件的函数,特别注意:若改为调用此方法则需要做兼容

func WrapResultFunc added in v2.2.0

func WrapResultFunc(f func(txSimContext protocol.TxSimContext, parameters map[string][]byte) ([]byte, error)) func(
	txSimContext protocol.TxSimContext, parameters map[string][]byte) *common.ContractResult

WrapResultFunc 包装原有的返回[]byte的函数,改为返回ContractResult的函数

Types

type Contract

type Contract interface {
	//GetMethod get register method by name
	GetMethod(methodName string) ContractFunc
}

Contract define native Contract interface

type ContractFunc

type ContractFunc func(context protocol.TxSimContext, params map[string][]byte) *common.ContractResult

ContractFunc invoke contract method, return result

Jump to

Keyboard shortcuts

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