1 Star 0 Fork 0

Hyperledger Fabric 国密 / fabric-sdk-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
opts.go 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
Jtyoui 提交于 2021-07-22 20:40 . 改造国密sdk
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package pkcs11
const (
defaultSessionCacheSize = 10
defaultOpenSessionRetry = 10
)
//ctxOpts options for conext handler
type ctxOpts struct {
//sessionCacheSize size of session cache pool
sessionCacheSize int
//openSessionRetry number of retry for open session logic
openSessionRetry int
//connectionName do maintain unique instances in cache for connections under same label and lib
connectionName string
}
//Options for PKCS11 ContextHandle
type Options func(opts *ctxOpts)
func getCtxOpts(opts ...Options) ctxOpts {
ctxOptions := ctxOpts{}
for _, option := range opts {
option(&ctxOptions)
}
if ctxOptions.sessionCacheSize == 0 {
ctxOptions.sessionCacheSize = defaultSessionCacheSize
}
if ctxOptions.openSessionRetry == 0 {
ctxOptions.openSessionRetry = defaultOpenSessionRetry
}
return ctxOptions
}
//WithSessionCacheSize size of session cache pool
func WithSessionCacheSize(size int) Options {
return func(o *ctxOpts) {
o.sessionCacheSize = size
}
}
//WithOpenSessionRetry number of retry for open session logic
func WithOpenSessionRetry(count int) Options {
return func(o *ctxOpts) {
o.openSessionRetry = count
}
}
//WithConnectionName name of connection to avoild collision with other connection instances in cache
//under same label and lib
func WithConnectionName(name string) Options {
return func(o *ctxOpts) {
o.connectionName = name
}
}
1
https://gitee.com/hyperledger-fabric-gm/fabric-sdk-go.git
git@gitee.com:hyperledger-fabric-gm/fabric-sdk-go.git
hyperledger-fabric-gm
fabric-sdk-go
fabric-sdk-go
3287af796e9e

搜索帮助