代码拉取完成,页面将自动刷新
// Copyright the Hyperledger Fabric contributors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package internal
import (
"context"
"time"
tls "gitee.com/zhaochuninhefei/gmgo/gmtls"
credentials "gitee.com/zhaochuninhefei/gmgo/gmtls/gmcredentials"
peerpb "github.com/hyperledger/fabric-protos-go/peer"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
)
const (
dialTimeout = 10 * time.Second
maxRecvMessageSize = 100 * 1024 * 1024 // 100 MiB
maxSendMessageSize = 100 * 1024 * 1024 // 100 MiB
)
// NewClientConn ...
func NewClientConn(
address string,
tlsConf *tls.Config,
kaOpts keepalive.ClientParameters,
) (*grpc.ClientConn, error) {
dialOpts := []grpc.DialOption{
grpc.WithKeepaliveParams(kaOpts),
grpc.WithBlock(),
grpc.FailOnNonTempDialError(true),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(maxRecvMessageSize),
grpc.MaxCallSendMsgSize(maxSendMessageSize),
),
}
if tlsConf != nil {
creds := credentials.NewTLS(tlsConf)
dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds))
} else {
dialOpts = append(dialOpts, grpc.WithInsecure())
}
ctx, cancel := context.WithTimeout(context.Background(), dialTimeout)
defer cancel()
return grpc.DialContext(ctx, address, dialOpts...)
}
// NewRegisterClient ...
func NewRegisterClient(conn *grpc.ClientConn) (peerpb.ChaincodeSupport_RegisterClient, error) {
return peerpb.NewChaincodeSupportClient(conn).Register(context.Background())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。