common

package
v0.0.0-...-7a628bf Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Copyright IBM Corp. 2016-2017 All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. 2016-2017 All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

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

UndefinedParamValue defines what undefined parameters in the command line will initialise to

Variables

View Source
var (

	// GetEndorserClientFnc is a function that returns a new endorser client connection
	// to the provided peer address using the TLS root cert file,
	// by default it is set to GetEndorserClient function
	GetEndorserClientFnc func(address, tlsRootCertFile string) (pb.EndorserClient, error)

	// GetPeerDeliverClientFnc is a function that returns a new deliver client connection
	// to the provided peer address using the TLS root cert file,
	// by default it is set to GetDeliverClient function
	GetPeerDeliverClientFnc func(address, tlsRootCertFile string) (pb.DeliverClient, error)

	// GetDeliverClientFnc is a function that returns a new deliver client connection
	// to the provided peer address using the TLS root cert file,
	// by default it is set to GetDeliverClient function
	GetDeliverClientFnc func(address, tlsRootCertFile string) (pb.Deliver_DeliverClient, error)

	// GetDefaultSignerFnc is a function that returns a default Signer(Default/PERR)
	// by default it is set to GetDefaultSigner function
	GetDefaultSignerFnc func() (msp.SigningIdentity, error)

	// GetBroadcastClientFnc returns an instance of the BroadcastClient interface
	// by default it is set to GetBroadcastClient function
	GetBroadcastClientFnc func() (BroadcastClient, error)

	// GetOrdererEndpointOfChainFnc returns orderer endpoints of given chain
	// by default it is set to GetOrdererEndpointOfChain function
	GetOrdererEndpointOfChainFnc func(chainID string, signer Signer,
		endorserClient pb.EndorserClient, cryptoProvider bccsp.BCCSP) ([]string, error)

	// GetCertificateFnc is a function that returns the client TLS certificate
	GetCertificateFnc func() (tls.Certificate, error)
)
View Source
var (
	OrderingEndpoint string
)

Functions

func AddOrdererFlags

func AddOrdererFlags(cmd *cobra.Command)

AddOrdererFlags adds flags for orderer-related commands

func CheckLogLevel

func CheckLogLevel(level string) error

CheckLogLevel checks that a given log level string is valid

func GetCertificate

func GetCertificate() (tls.Certificate, error)

GetCertificate returns the client's TLS certificate

func GetDefaultSigner

func GetDefaultSigner() (msp.SigningIdentity, error)

GetDefaultSigner return a default Signer(Default/PEER) for cli

func GetDeliverClient

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

GetDeliverClient returns a new deliver client. If both the address and tlsRootCertFile are not provided, the target values for the client are taken from the configuration settings for "peer.address" and "peer.tls.rootcert.file"

func GetEndorserClient

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

GetEndorserClient returns a new endorser client. If the both the address and tlsRootCertFile are not provided, the target values for the client are taken from the configuration settings for "peer.address" and "peer.tls.rootcert.file"

func GetMockEndorserClient

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

GetMockEndorserClient return a endorser client return specified ProposalResponse and err(nil or error)

func GetOrdererEndpointOfChain

func GetOrdererEndpointOfChain(chainID string, signer Signer, endorserClient pb.EndorserClient, cryptoProvider bccsp.BCCSP) ([]string, error)

GetOrdererEndpointOfChain returns orderer endpoints of given chain

func GetPeerDeliverClient

func GetPeerDeliverClient(address, tlsRootCertFile string) (pb.DeliverClient, error)

GetPeerDeliverClient returns a new deliver client. If both the address and tlsRootCertFile are not provided, the target values for the client are taken from the configuration settings for "peer.address" and "peer.tls.rootcert.file"

func InitCmd

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

func InitConfig

func InitConfig(cmdRoot string) error

InitConfig initializes viper config

func InitCrypto

func InitCrypto(mspMgrConfigDir, localMSPID, localMSPType string) error

InitCrypto initializes crypto for this peer

func SetBCCSPKeystorePath

func SetBCCSPKeystorePath()

SetBCCSPKeystorePath sets the file keystore path for the SW BCCSP provider to an absolute path relative to the config file

func SetOrdererEnv

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

SetOrdererEnv adds orderer-specific settings to the global Viper environment

Types

type BroadcastClient

type BroadcastClient interface {
	//Send data to orderer
	Send(env *cb.Envelope) error
	Close() error
}

func GetBroadcastClient

func GetBroadcastClient() (BroadcastClient, error)

GetBroadcastClient creates a simple instance of the BroadcastClient interface

func GetMockBroadcastClient

func GetMockBroadcastClient(err error) BroadcastClient

type BroadcastGRPCClient

type BroadcastGRPCClient struct {
	Client ab.AtomicBroadcast_BroadcastClient
}

func (*BroadcastGRPCClient) Close

func (s *BroadcastGRPCClient) Close() error

func (*BroadcastGRPCClient) Send

func (s *BroadcastGRPCClient) Send(env *cb.Envelope) error

Send data to orderer

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 defines a CA configuration not currently used by CLI

type CCType

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

CCType - not currently used by CLI

type ChannelNetworkConfig

type ChannelNetworkConfig struct {
	// Orderers list of ordering service nodes
	Orderers []string `yaml:"orderers"`
	// Peers a list of peer-channels that are part of this organization
	// to get the real Peer config object, use the Name field and fetch NetworkConfig.Peers[Name]
	Peers map[string]PeerChannelConfig `yaml:"peers"`
	// Chaincodes list of services
	Chaincodes []string `yaml:"chaincodes"`
}

ChannelNetworkConfig provides the definition of channels for the network

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 - not currently used by CLI

type CommonClient

type CommonClient struct {
	*comm.GRPCClient
	Address string
	// contains filtered or unexported fields
}

type CredentialStoreType

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

CredentialStoreType - not currently used by CLI

type DeliverClient

type DeliverClient struct {
	Signer      identity.SignerSerializer
	Service     ab.AtomicBroadcast_DeliverClient
	ChannelID   string
	TLSCertHash []byte
	BestEffort  bool
}

DeliverClient holds the necessary information to connect a client to an orderer/peer deliver service

func NewDeliverClientForOrderer

func NewDeliverClientForOrderer(channelID string, signer identity.SignerSerializer, bestEffort bool) (*DeliverClient, error)

NewDeliverClientForOrderer creates a new DeliverClient from an OrdererClient

func NewDeliverClientForPeer

func NewDeliverClientForPeer(channelID string, signer identity.SignerSerializer, bestEffort bool) (*DeliverClient, error)

NewDeliverClientForPeer creates a new DeliverClient from a PeerClient

func (*DeliverClient) Close

func (d *DeliverClient) Close() error

Close closes a deliver client's connection

func (*DeliverClient) GetNewestBlock

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

GetNewestBlock gets the newest block from a peer/orderer's deliver service

func (*DeliverClient) GetOldestBlock

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

GetOldestBlock gets the oldest block from a peer/orderer's deliver service

func (*DeliverClient) GetSpecifiedBlock

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

GetSpecifiedBlock gets the specified block from a peer/orderer's deliver service

type EnrollCredentials

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

EnrollCredentials holds credentials used for enrollment not currently used by CLI

type LoggingType

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

LoggingType not currently used by CLI

type MutualTLSConfig

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

	// Certfiles root certificates for TLS validation (Comma separated path list)
	Path string `yaml:"path"`

	//Client TLS information
	Client TLSKeyPair `yaml:"client"`
}

MutualTLSConfig Mutual TLS configurations not currently used by 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 provides a static definition of a Hyperledger Fabric network

func GetConfig

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

GetConfig unmarshals the provided connection profile into a network configuration struct

type OrdererClient

type OrdererClient struct {
	CommonClient
}

OrdererClient represents a client for communicating with an ordering service

func NewOrdererClientFromEnv

func NewOrdererClientFromEnv() (*OrdererClient, error)

NewOrdererClientFromEnv creates an instance of an OrdererClient from the global Viper instance

func (*OrdererClient) Broadcast

Broadcast returns a broadcast client for the AtomicBroadcast service

func (*OrdererClient) Certificate

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

Certificate returns the TLS client certificate (if available)

func (*OrdererClient) Deliver

Deliver returns a deliver client for the AtomicBroadcast service

type OrdererConfig

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

OrdererConfig defines an orderer configuration not currently used by 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 provides the definition of an organization in the network not currently used by CLI

type PeerChannelConfig

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

PeerChannelConfig defines the peer capabilities

type PeerClient

type PeerClient struct {
	CommonClient
}

PeerClient represents a client for communicating with a peer

func NewPeerClientForAddress

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

NewPeerClientForAddress creates an instance of a PeerClient using the provided peer address and, if TLS is enabled, the TLS root cert file

func NewPeerClientFromEnv

func NewPeerClientFromEnv() (*PeerClient, error)

NewPeerClientFromEnv creates an instance of a PeerClient from the global Viper instance

func (*PeerClient) Certificate

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

Certificate returns the TLS client certificate (if available)

func (*PeerClient) Deliver

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

Deliver returns a client for the Deliver service

func (*PeerClient) Endorser

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

Endorser returns a client for the Endorser service

func (*PeerClient) PeerDeliver

func (pc *PeerClient) PeerDeliver() (pb.DeliverClient, error)

PeerDeliver returns a client for the Deliver service for peer-specific use cases (i.e. DeliverFiltered)

type PeerConfig

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

PeerConfig defines a peer configuration

type Signer

type Signer interface {
	Sign(msg []byte) ([]byte, error)
	Serialize() ([]byte, error)
}

Signer defines the interface needed for signing messages

type TLSConfig

type TLSConfig struct {
	// the following two fields are interchangeable.
	// If Path is available, then it will be used to load the cert
	// if Pem is available, then it has the raw data of the cert it will be used as-is
	// Certificate root certificate path
	Path string `yaml:"path"`
	// Certificate actual content
	Pem string `yaml:"pem"`
}

TLSConfig TLS configurations

type TLSKeyPair

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

TLSKeyPair contains the private key and certificate for TLS encryption not currently used by CLI

type TLSType

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

TLSType - not currently used by CLI

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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