Documentation ¶
Overview ¶
Package common is package for common
Index ¶
- Constants
- Variables
- func GetChainConfig(txSimContext protocol.TxSimContext) (*configPb.ChainConfig, error)
- func GetChainConfigNoRecord(txSimContext protocol.TxSimContext) (*configPb.ChainConfig, error)
- func GetGas(contractName, method string, defaultGas uint64) uint64
- func GetPkFromMemberFull(memberFull *accesscontrol.MemberFull) ([]byte, error)
- func GetSenderMemberFull(txSimContext protocol.TxSimContext, log protocol.Logger) (*accesscontrol.MemberFull, error)
- func GetSenderPublicKey(txSimContext protocol.TxSimContext) ([]byte, error)
- func PublicKeyToAddress(publicKey []byte, chainCfg *configPb.ChainConfig) (string, error)
- func ResultBytesAndError(returnResult []byte, event []*common.ContractEvent, err error) *common.ContractResult
- func ResultError(err error) *common.ContractResult
- func ResultErrorWithGasUsed(err error, gas uint64) *common.ContractResult
- func ResultJson(obj interface{}) (*common.ContractResult, error)
- func ResultSuccess(result []byte, gas uint64) *common.ContractResult
- func VerifyAndToLowerAddress(context protocol.TxSimContext, address string) (string, bool)
- func VerifyAndToLowerAddress2(blockVersion uint32, addrType configPb.AddrType, address string) (string, bool)
- func WrapEventResult(...) ...
- func WrapResultFunc(...) ...
- type Contract
- type ContractFunc
- type TruncateConfig
- func (t *TruncateConfig) TruncateBlock(b *commonPb.Block)
- func (t *TruncateConfig) TruncateBlockWithRWSet(b *commonPb.BlockInfo)
- func (t *TruncateConfig) TruncatePayload(payload *commonPb.Payload)
- func (t *TruncateConfig) TruncateRWSet(rwset *commonPb.TxRWSet)
- func (t *TruncateConfig) TruncateTx(tx *commonPb.Transaction)
Constants ¶
const DefaultGas = uint64(100000)
DefaultGas 默认的Gas值
Variables ¶
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
GetGas 获得一个系统合约的某个方法的Gas值,如果没有配置,则返回默认的Gas值
func GetPkFromMemberFull ¶ added in v2.3.4
func GetPkFromMemberFull(memberFull *accesscontrol.MemberFull) ([]byte, error)
GetPkFromMemberFull get the public key bytes of memberFull
func GetSenderMemberFull ¶ added in v2.3.4
func GetSenderMemberFull(txSimContext protocol.TxSimContext, log protocol.Logger) (*accesscontrol.MemberFull, error)
GetSenderMemberFull return MemberFull data identifying the sender of tx
func GetSenderPublicKey ¶ added in v2.3.3
GetSenderPublicKey get tx sender public key @param txSimContext @return []byte public key @return error
func PublicKeyToAddress ¶ added in v2.3.3
func PublicKeyToAddress(publicKey []byte, chainCfg *configPb.ChainConfig) (string, error)
PublicKeyToAddress publicKey to address @param publicKey @param chainCfg chain config @return string as "760352ae678c378a86e03ccad56c3d2d712134ed" "0X760352ae678c378a86e03ccad56c3d2d712134ed" @error
func ResultBytesAndError ¶ added in v2.2.0
func ResultBytesAndError(returnResult []byte, event []*common.ContractEvent, err error) *common.ContractResult
ResultBytesAndError make *common.ContractResult with data, event, 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 VerifyAndToLowerAddress ¶ added in v2.3.3
VerifyAndToLowerAddress by TxSimContext @param context @param address as "A60352ae678c378a86e03ccad56c3d2d712134ed" "0X760352ae678c378a86e03ccad56c3d2d712134ed" @return string as "a60352ae678c378a86e03ccad56c3d2d712134ed" "0x760352ae678c378a86e03ccad56c3d2d712134ed" @error
func VerifyAndToLowerAddress2 ¶ added in v2.3.3
func VerifyAndToLowerAddress2(blockVersion uint32, addrType configPb.AddrType, address string) (string, bool)
VerifyAndToLowerAddress2 by blockVersion addrType @param blockVersion @param addrType as "A60352ae678c378a86e03ccad56c3d2d712134ed" "760352ae678c378a86e03ccad56c3d2d712134ed" @return address as "a60352ae678c378a86e03ccad56c3d2d712134ed" "760352ae678c378a86e03ccad56c3d2d712134ed" @bool is valid address
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和事件的函数,特别注意:若改为调用此方法则需要做兼容
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
type TruncateConfig ¶ added in v2.3.3
type TruncateConfig struct {
// contains filtered or unexported fields
}
TruncateConfig util to truncate struct field size
func NewTruncateConfig ¶ added in v2.3.3
func NewTruncateConfig(truncateValueLen int, truncateModel string) *TruncateConfig
NewTruncateConfig 创建一个裁剪操作对象 @param truncateValueLen @param truncateModel @return *TruncateConfig
func (*TruncateConfig) TruncateBlock ¶ added in v2.3.3
func (t *TruncateConfig) TruncateBlock(b *commonPb.Block)
TruncateBlock 裁剪区块 @param b
func (*TruncateConfig) TruncateBlockWithRWSet ¶ added in v2.3.3
func (t *TruncateConfig) TruncateBlockWithRWSet(b *commonPb.BlockInfo)
TruncateBlockWithRWSet 裁剪区块和读写集 @param b
func (*TruncateConfig) TruncatePayload ¶ added in v2.3.3
func (t *TruncateConfig) TruncatePayload(payload *commonPb.Payload)
TruncatePayload 裁剪交易 @param payload
func (*TruncateConfig) TruncateRWSet ¶ added in v2.3.3
func (t *TruncateConfig) TruncateRWSet(rwset *commonPb.TxRWSet)
TruncateRWSet 裁剪读写集 @param rwset
func (*TruncateConfig) TruncateTx ¶ added in v2.3.3
func (t *TruncateConfig) TruncateTx(tx *commonPb.Transaction)
TruncateTx 裁剪交易 @param tx