cmclient

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

使用Go-SDK开发ChainMakerClient

如何使用

1.配置文件

将客户端的配置文件放在testdata中

2.在go-zero的etc中的config.yaml中加入以下配置
SdkConfigPath: ../testdata/sdk_config.yml
3.在config.go中加入以下配置
type Config struct {
    SdkConfigPath string
}
4.在service_context.go中加入以下代码
type ServiceContext struct {
	Config config.Config
	CMClient *sdk.ChainClient
}

func NewServiceContext(c config.Config) *ServiceContext {
	cmClient, err := cmclient.CreateCMClient(c.SdkConfigPath)
	if err != nil {
		panic("create client Failed,error:" + err.Error())
	}
	return &ServiceContext{
		Config: c,
		CMClient: cmClient,
	}
}
这样就可以在logic中通过logic将client传入到service中

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCMClient

func CreateCMClient(sdkConfigPath string, opts ...sdk.ChainClientOption) (*sdk.ChainClient, error)

CreateCMClient 创建长安链客户端 chainMaker

Types

type LogAdapter

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

LogAdapter 是 logx.Logger 到 utils.Logger 的适配器

func NewLogAdapter

func NewLogAdapter(log logx.Logger) *LogAdapter

NewLogAdapter 创建 LogAdapter 实例

func (*LogAdapter) Debug

func (la *LogAdapter) Debug(args ...interface{})

func (*LogAdapter) Debugf

func (la *LogAdapter) Debugf(format string, args ...interface{})

func (*LogAdapter) Error

func (la *LogAdapter) Error(args ...interface{})

func (*LogAdapter) Errorf

func (la *LogAdapter) Errorf(format string, args ...interface{})

func (*LogAdapter) Info

func (la *LogAdapter) Info(args ...interface{})

func (*LogAdapter) Infof

func (la *LogAdapter) Infof(format string, args ...interface{})

func (*LogAdapter) Warn

func (la *LogAdapter) Warn(args ...interface{})

Warn 实现 utils.Logger 接口中的 Warn 方法

func (*LogAdapter) Warnf

func (la *LogAdapter) Warnf(format string, args ...interface{})

Warnf 实现 utils.Logger 接口中的 Warnf 方法

Directories

Path Synopsis
subscribe
event
Created by guoxin in 2024/7/4 下午5:01
Created by guoxin in 2024/7/4 下午5:01

Jump to

Keyboard shortcuts

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