common

package
v0.0.0-...-523a819 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const CmdRoot = "core"
View Source
const UndefinedParamValue = ""

UndefinedParamValue定义命令行中未定义的参数将初始化为什么

Variables

View Source
var (

	//Get背书器Clientfnc是一个返回新背书器客户端连接的函数
	//到使用tls根证书文件提供的对等地址,
	//默认情况下,它设置为Get背书客户端函数
	GetEndorserClientFnc func(address, tlsRootCertFile string) (pb.EndorserClient, error)

	//GetPeerDeliverClientFnc是一个返回新的传递客户端连接的函数
	//到使用tls根证书文件提供的对等地址,
	//默认设置为GetDeliverClient函数
	GetPeerDeliverClientFnc func(address, tlsRootCertFile string) (api.PeerDeliverClient, error)

	//GetDeliverClientFnc是一个返回新的传递客户端连接的函数
	//到使用tls根证书文件提供的对等地址,
	//默认设置为GetDeliverClient函数
	GetDeliverClientFnc func(address, tlsRootCertFile string) (pb.Deliver_DeliverClient, error)

	//GetDefaultSignerFnc是一个返回默认签名者(default/perr)的函数。
	//默认设置为GetDefaultSigner函数
	GetDefaultSignerFnc func() (msp.SigningIdentity, error)

	//GetBroadcastClientFnc返回BroadcastClient接口的实例
	//默认设置为getBroadcastClient函数
	GetBroadcastClientFnc func() (BroadcastClient, error)

	//getorderendpointtochainfnc返回给定链的排序器端点
	//默认情况下,它被设置为getorderendpointtochain函数
	GetOrdererEndpointOfChainFnc func(chainID string, signer msp.SigningIdentity,
		endorserClient pb.EndorserClient) ([]string, error)

	//getCertificateFnc是返回客户端TLS证书的函数
	GetCertificateFnc func() (tls.Certificate, error)
)
View Source
var (
	OrderingEndpoint string
)

Functions

func AddOrdererFlags

func AddOrdererFlags(cmd *cobra.Command)

addorderflags为与排序器相关的命令添加标志

func CheckLogLevel

func CheckLogLevel(level string) error

checkloglevel检查给定的日志级别字符串是否有效

func GetAdminClient

func GetAdminClient() (pb.AdminClient, error)

GetAdminClient返回新的管理客户端。的目标地址 客户端取自配置设置“peer.address”

func GetCertificate

func GetCertificate() (tls.Certificate, error)

getCertificate返回客户端的TLS证书

func GetDefaultSigner

func GetDefaultSigner() (msp.SigningIdentity, error)

getdefaultsigner为cli返回默认签名者(default/perr)

func GetDeliverClient

func GetDeliverClient(address, tlsRootCertFile string) (pb.Deliver_DeliverClient, error)

GetDeliverClient返回新的传递客户端。如果地址和 未提供tlsrootcertfile,将获取客户端的目标值 从“peer.address”和的配置设置 “对等.tls.rootcert.file”

func GetEndorserClient

func GetEndorserClient(address, tlsRootCertFile string) (pb.EndorserClient, error)

Get背书人客户端返回新的背书人客户端。如果地址和 未提供tlsrootcertfile,将获取客户端的目标值 从“peer.address”和的配置设置 “对等.tls.rootcert.file”

func GetMockAdminClient

func GetMockAdminClient(err error) pb.AdminClient

func GetMockEndorserClient

func GetMockEndorserClient(response *pb.ProposalResponse, err error) pb.EndorserClient

GetMock背书客户端返回背书客户端返回指定的ProposalResponse和Err(零或错误)

func GetOrdererEndpointOfChain

func GetOrdererEndpointOfChain(chainID string, signer msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error)

getorderEndpointToChain返回给定链的排序器终结点

func GetPeerDeliverClient

func GetPeerDeliverClient(address, tlsRootCertFile string) (api.PeerDeliverClient, error)

GetPeerDeliverClient返回新的传递客户端。如果地址和 未提供tlsrootcertfile,将获取客户端的目标值 从“peer.address”和的配置设置 “对等.tls.rootcert.file”

func InitCmd

func InitCmd(cmd *cobra.Command, args []string)

func InitConfig

func InitConfig(cmdRoot string) error

initconfig初始化viper配置

func InitCrypto

func InitCrypto(mspMgrConfigDir, localMSPID, localMSPType string) error

InitCrypto初始化此对等机的加密

func SetBCCSPKeystorePath

func SetBCCSPKeystorePath()

setbccspkeystorepath为sw bccsp提供程序设置文件密钥库路径 相对于配置文件的绝对路径

func SetOrdererEnv

func SetOrdererEnv(cmd *cobra.Command, args []string)

setorderenv将特定于医嘱者的设置添加到全局viper环境中

Types

type BroadcastClient

type BroadcastClient interface {
	//向订购方发送数据
	Send(env *cb.Envelope) error
	Close() error
}

func GetBroadcastClient

func GetBroadcastClient() (BroadcastClient, error)

GetBroadcastClient创建BroadcastClient接口的简单实例

func GetMockBroadcastClient

func GetMockBroadcastClient(err error) BroadcastClient

type CAConfig

type CAConfig struct {
	URL         string                 `yaml:"url"`
	HTTPOptions map[string]interface{} `yaml:"httpOptions"`
	TLSCACerts  MutualTLSConfig        `yaml:"tlsCACerts"`
	Registrar   EnrollCredentials      `yaml:"registrar"`
	CaName      string                 `yaml:"caName"`
}

caconfig定义CA配置 当前未被CLI使用

type CCType

type CCType struct {
	Path string `yaml:"path"`
}

cctype-当前未由cli使用

type ChannelNetworkConfig

type ChannelNetworkConfig struct {
	//订购者订购服务节点列表
	Orderers []string `yaml:"orderers"`
	//对等端此组织中的对等通道列表
	//要获取真正的对等配置对象,请使用名称字段并获取networkconfig.peers[名称]
	Peers map[string]PeerChannelConfig `yaml:"peers"`
	//链码服务清单
	Chaincodes []string `yaml:"chaincodes"`
}

channelnetworkconfig提供网络的通道定义

type ClientConfig

type ClientConfig struct {
	Organization    string              `yaml:"organization"`
	Logging         LoggingType         `yaml:"logging"`
	CryptoConfig    CCType              `yaml:"cryptoconfig"`
	TLS             TLSType             `yaml:"tls"`
	CredentialStore CredentialStoreType `yaml:"credentialStore"`
}

clientconfig-当前未被cli使用

type CredentialStoreType

type CredentialStoreType struct {
	Path        string `yaml:"path"`
	CryptoStore struct {
		Path string `yaml:"path"`
	}
	Wallet string `yaml:"wallet"`
}

CredentialStoreType-当前未由CLI使用

type DeliverClient

type DeliverClient struct {
	Service     api.DeliverService
	ChannelID   string
	TLSCertHash []byte
}

DeliverClient保存连接客户端所需的信息 到订购方/对等交付服务

func NewDeliverClientForOrderer

func NewDeliverClientForOrderer(channelID string) (*DeliverClient, error)

newdeliverclientfororder从orderclient创建新的deliverclient

func NewDeliverClientForPeer

func NewDeliverClientForPeer(channelID string) (*DeliverClient, error)

NewDeliverClientforPeer从对等客户端创建新的DeliverClient

func (*DeliverClient) Close

func (d *DeliverClient) Close() error

关闭关闭传递客户端的连接

func (*DeliverClient) GetNewestBlock

func (d *DeliverClient) GetNewestBlock() (*cb.Block, error)

getnewestblock从对等方/订购方的传递服务获取最新的块

func (*DeliverClient) GetOldestBlock

func (d *DeliverClient) GetOldestBlock() (*cb.Block, error)

GetOldestBlock从对等方/订购方的传递服务获取最旧的块

func (*DeliverClient) GetSpecifiedBlock

func (d *DeliverClient) GetSpecifiedBlock(num uint64) (*cb.Block, error)

GetSpecifiedBlock从对等方/订购方的交货中获取指定的块 服务

type EnrollCredentials

type EnrollCredentials struct {
	EnrollID     string `yaml:"enrollId"`
	EnrollSecret string `yaml:"enrollSecret"`
}

注册凭据保留用于注册的凭据 当前未被CLI使用

type LoggingType

type LoggingType struct {
	Level string `yaml:"level"`
}

cli当前未使用loggingtype

type MutualTLSConfig

type MutualTLSConfig struct {
	Pem []string `yaml:"pem"`

	//certfiles用于TLS验证的根证书(逗号分隔的路径列表)
	Path string `yaml:"path"`

	//客户端TLS信息
	Client TLSKeyPair `yaml:"client"`
}

MutualTlsConfig相互TLS配置 当前未被CLI使用

type NetworkConfig

type NetworkConfig struct {
	Name                   string                          `yaml:"name"`
	Xtype                  string                          `yaml:"x-type"`
	Description            string                          `yaml:"description"`
	Version                string                          `yaml:"version"`
	Channels               map[string]ChannelNetworkConfig `yaml:"channels"`
	Organizations          map[string]OrganizationConfig   `yaml:"organizations"`
	Peers                  map[string]PeerConfig           `yaml:"peers"`
	Client                 ClientConfig                    `yaml:"client"`
	Orderers               map[string]OrdererConfig        `yaml:"orderers"`
	CertificateAuthorities map[string]CAConfig             `yaml:"certificateAuthorities"`
}

networkconfig提供了超级账本结构网络的静态定义

func GetConfig

func GetConfig(fileName string) (*NetworkConfig, error)

getconfig将提供的连接配置文件取消标记到网络中 配置结构

type OrdererClient

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

OrdererClient表示用于与订单通信的客户端 服务

func NewOrdererClientFromEnv

func NewOrdererClientFromEnv() (*OrdererClient, error)

NewOrdererClientfromenv从 全局毒蛇实例

func (*OrdererClient) Broadcast

广播返回原子广播服务的广播客户端

func (*OrdererClient) Certificate

func (oc *OrdererClient) Certificate() tls.Certificate

证书返回TLS客户端证书(如果可用)

func (*OrdererClient) Deliver

Deliver返回AtomicBroadcast服务的Deliver客户端

type OrdererConfig

type OrdererConfig struct {
	URL         string                 `yaml:"url"`
	GrpcOptions map[string]interface{} `yaml:"grpcOptions"`
	TLSCACerts  TLSConfig              `yaml:"tlsCACerts"`
}

orderconfig定义了一个order配置 当前未被CLI使用

type OrganizationConfig

type OrganizationConfig struct {
	MspID                  string    `yaml:"mspid"`
	Peers                  []string  `yaml:"peers"`
	CryptoPath             string    `yaml:"cryptoPath"`
	CertificateAuthorities []string  `yaml:"certificateAuthorities"`
	AdminPrivateKey        TLSConfig `yaml:"adminPrivateKey"`
	SignedCert             TLSConfig `yaml:"signedCert"`
}

OrganizationConfig提供网络中组织的定义 当前未被CLI使用

type PeerChannelConfig

type PeerChannelConfig struct {
	EndorsingPeer  bool `yaml:"endorsingPeer"`
	ChaincodeQuery bool `yaml:"chaincodeQuery"`
	LedgerQuery    bool `yaml:"ledgerQuery"`
	EventSource    bool `yaml:"eventSource"`
}

peerchannelconfig定义对等功能

type PeerClient

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

PeerClient表示与对等机通信的客户端

func NewPeerClientForAddress

func NewPeerClientForAddress(address, tlsRootCertFile string) (*PeerClient, error)

newpeerclientforaddress使用 提供对等地址,如果启用了tls,则提供tls根证书文件

func NewPeerClientFromEnv

func NewPeerClientFromEnv() (*PeerClient, error)

newpeerclientfromenv从全局创建peerclient的实例 蝰蛇实例

func (*PeerClient) Admin

func (pc *PeerClient) Admin() (pb.AdminClient, error)

admin返回管理服务的客户端

func (*PeerClient) Certificate

func (pc *PeerClient) Certificate() tls.Certificate

证书返回TLS客户端证书(如果可用)

func (*PeerClient) Deliver

func (pc *PeerClient) Deliver() (pb.Deliver_DeliverClient, error)

Deliver返回Deliver服务的客户端

func (*PeerClient) Endorser

func (pc *PeerClient) Endorser() (pb.EndorserClient, error)

背书人返回背书人服务的客户

func (*PeerClient) PeerDeliver

func (pc *PeerClient) PeerDeliver() (api.PeerDeliverClient, error)

PeerDeliver返回用于传递服务的客户端以供对等端特定使用 案例(即筛选的交付)

type PeerConfig

type PeerConfig struct {
	URL         string                 `yaml:"url"`
	EventURL    string                 `yaml:"eventUrl"`
	GRPCOptions map[string]interface{} `yaml:"grpcOptions"`
	TLSCACerts  TLSConfig              `yaml:"tlsCACerts"`
}

peerconfig定义对等配置

type PeerDeliverClient

type PeerDeliverClient struct {
	Client pb.DeliverClient
}

PeerDeliverClient保存连接客户端所需的信息 到对等交付服务

func (PeerDeliverClient) Deliver

func (dc PeerDeliverClient) Deliver(ctx context.Context, opts ...grpc.CallOption) (ccapi.Deliver, error)

传递将客户端连接到传递RPC

func (PeerDeliverClient) DeliverFiltered

func (dc PeerDeliverClient) DeliverFiltered(ctx context.Context, opts ...grpc.CallOption) (ccapi.Deliver, error)

deliverfiltered将客户端连接到deliverfiltered rpc

type TLSConfig

type TLSConfig struct {
	//以下两个字段可以互换。
	//如果路径可用,则它将用于加载证书
	//如果PEM可用,则它具有证书的原始数据,将按原样使用。
	//证书根证书路径
	Path string `yaml:"path"`
	//证书实际内容
	Pem string `yaml:"pem"`
}

tlsconfig tls配置

type TLSKeyPair

type TLSKeyPair struct {
	Key  TLSConfig `yaml:"key"`
	Cert TLSConfig `yaml:"cert"`
}

tlskeypair包含用于tls加密的私钥和证书 当前未被CLI使用

type TLSType

type TLSType struct {
	Enabled bool `yaml:"enabled"`
}

tlstype-当前未被cli使用

Directories

Path Synopsis
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 伪造者生成的代码。
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 伪造者生成的代码。

Jump to

Keyboard shortcuts

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