63 Star 181 Fork 3

Gitee 极速下载 / hyperledger-fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
config.go 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package library
import (
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
)
// Config configures the factory methods
// and plugins for the registry
type Config struct {
AuthFilters []*HandlerConfig `mapstructure:"authFilters" yaml:"authFilters"`
Decorators []*HandlerConfig `mapstructure:"decorators" yaml:"decorators"`
Endorsers PluginMapping `mapstructure:"endorsers" yaml:"endorsers"`
Validators PluginMapping `mapstructure:"validators" yaml:"validators"`
}
// PluginMapping stores a map between chaincode id to plugin config
type PluginMapping map[string]*HandlerConfig
// HandlerConfig defines configuration for a plugin or compiled handler
type HandlerConfig struct {
Name string `mapstructure:"name" yaml:"name"`
Library string `mapstructure:"library" yaml:"library"`
}
func LoadConfig() (Config, error) {
var authFilters, decorators []*HandlerConfig
if err := mapstructure.Decode(viper.Get("peer.handlers.authFilters"), &authFilters); err != nil {
return Config{}, err
}
if err := mapstructure.Decode(viper.Get("peer.handlers.decorators"), &decorators); err != nil {
return Config{}, err
}
endorsers, validators := make(PluginMapping), make(PluginMapping)
e := viper.GetStringMap("peer.handlers.endorsers")
for k := range e {
name := viper.GetString("peer.handlers.endorsers." + k + ".name")
library := viper.GetString("peer.handlers.endorsers." + k + ".library")
endorsers[k] = &HandlerConfig{Name: name, Library: library}
}
v := viper.GetStringMap("peer.handlers.validators")
for k := range v {
name := viper.GetString("peer.handlers.validators." + k + ".name")
library := viper.GetString("peer.handlers.validators." + k + ".library")
validators[k] = &HandlerConfig{Name: name, Library: library}
}
return Config{
AuthFilters: authFilters,
Decorators: decorators,
Endorsers: endorsers,
Validators: validators,
}, nil
}
Go
1
https://gitee.com/mirrors/hyperledger-fabric.git
git@gitee.com:mirrors/hyperledger-fabric.git
mirrors
hyperledger-fabric
hyperledger-fabric
v2.1.1

搜索帮助