const CmdRoot = "core"
UndefinedParamValue defines what undefined parameters in the command line will initialise to
const UndefinedParamValue = ""
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) (api.PeerDeliverClient, 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 msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error) // GetCertificateFnc is a function that returns the client TLS certificate GetCertificateFnc func() (tls.Certificate, error) )
var ( OrderingEndpoint string )
func AddOrdererFlags(cmd *cobra.Command)
AddOrdererFlags adds flags for orderer-related commands
func CheckLogLevel(level string) error
CheckLogLevel checks that a given log level string is valid
func GetAdminClient() (pb.AdminClient, error)
GetAdminClient returns a new admin client. The target address for the client is taken from the configuration setting "peer.address"
func GetCertificate() (tls.Certificate, error)
GetCertificate returns the client's TLS certificate
func GetDefaultSigner() (msp.SigningIdentity, error)
GetDefaultSigner return a default Signer(Default/PERR) for cli
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(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 GetMockAdminClient(err error) pb.AdminClient
func GetMockEndorserClient(response *pb.ProposalResponse, err error) pb.EndorserClient
GetMockEndorserClient return a endorser client return specified ProposalResponse and err(nil or error)
func GetOrdererEndpointOfChain(chainID string, signer msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error)
GetOrdererEndpointOfChain returns orderer endpoints of given chain
func GetPeerDeliverClient(address, tlsRootCertFile string) (api.PeerDeliverClient, 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(cmd *cobra.Command, args []string)
func InitConfig(cmdRoot string) error
InitConfig initializes viper config
func InitCrypto(mspMgrConfigDir, localMSPID, localMSPType string) error
InitCrypto initializes crypto for this peer
func SetBCCSPKeystorePath()
SetBCCSPKeystorePath sets the file keystore path for the SW BCCSP provider to an absolute path relative to the config file
func SetOrdererEnv(cmd *cobra.Command, args []string)
SetOrdererEnv adds orderer-specific settings to the global Viper environment
type BroadcastClient interface { //Send data to orderer Send(env *cb.Envelope) error Close() error }
func GetBroadcastClient() (BroadcastClient, error)
GetBroadcastClient creates a simple instance of the BroadcastClient interface
func GetMockBroadcastClient(err error) BroadcastClient
CAConfig defines a CA configuration not currently used by CLI
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"` }
CCType - not currently used by CLI
type CCType struct { Path string `yaml:"path"` }
ChannelNetworkConfig provides the definition of channels for the network
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"` }
ClientConfig - not currently used by CLI
type ClientConfig struct { Organization string `yaml:"organization"` Logging LoggingType `yaml:"logging"` CryptoConfig CCType `yaml:"cryptoconfig"` TLS TLSType `yaml:"tls"` CredentialStore CredentialStoreType `yaml:"credentialStore"` }
CredentialStoreType - not currently used by CLI
type CredentialStoreType struct { Path string `yaml:"path"` CryptoStore struct { Path string `yaml:"path"` } Wallet string `yaml:"wallet"` }
DeliverClient holds the necessary information to connect a client to an orderer/peer deliver service
type DeliverClient struct { Service api.DeliverService ChannelID string TLSCertHash []byte BestEffort bool }
func NewDeliverClientForOrderer(channelID string, bestEffort bool) (*DeliverClient, error)
NewDeliverClientForOrderer creates a new DeliverClient from an OrdererClient
func NewDeliverClientForPeer(channelID string, bestEffort bool) (*DeliverClient, error)
NewDeliverClientForPeer creates a new DeliverClient from a PeerClient
func (d *DeliverClient) Close() error
Close closes a deliver client's connection
func (d *DeliverClient) GetNewestBlock() (*cb.Block, error)
GetNewestBlock gets the newest block from a peer/orderer's deliver service
func (d *DeliverClient) GetOldestBlock() (*cb.Block, error)
GetOldestBlock gets the oldest block from a peer/orderer's deliver service
func (d *DeliverClient) GetSpecifiedBlock(num uint64) (*cb.Block, error)
GetSpecifiedBlock gets the specified block from a peer/orderer's deliver service
EnrollCredentials holds credentials used for enrollment not currently used by CLI
type EnrollCredentials struct { EnrollID string `yaml:"enrollId"` EnrollSecret string `yaml:"enrollSecret"` }
LoggingType not currently used by CLI
type LoggingType struct { Level string `yaml:"level"` }
MutualTLSConfig Mutual TLS configurations not currently used by CLI
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"` }
NetworkConfig provides a static definition of a Hyperledger Fabric network
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"` }
func GetConfig(fileName string) (*NetworkConfig, error)
GetConfig unmarshals the provided connection profile into a network configuration struct
OrdererClient represents a client for communicating with an ordering service
type OrdererClient struct {
// contains filtered or unexported fields
}
func NewOrdererClientFromEnv() (*OrdererClient, error)
NewOrdererClientFromEnv creates an instance of an OrdererClient from the global Viper instance
func (oc *OrdererClient) Broadcast() (ab.AtomicBroadcast_BroadcastClient, error)
Broadcast returns a broadcast client for the AtomicBroadcast service
func (oc *OrdererClient) Certificate() tls.Certificate
Certificate returns the TLS client certificate (if available)
func (oc *OrdererClient) Deliver() (ab.AtomicBroadcast_DeliverClient, error)
Deliver returns a deliver client for the AtomicBroadcast service
OrdererConfig defines an orderer configuration not currently used by CLI
type OrdererConfig struct { URL string `yaml:"url"` GrpcOptions map[string]interface{} `yaml:"grpcOptions"` TLSCACerts TLSConfig `yaml:"tlsCACerts"` }
OrganizationConfig provides the definition of an organization in the network not currently used by CLI
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"` }
PeerChannelConfig defines the peer capabilities
type PeerChannelConfig struct { EndorsingPeer bool `yaml:"endorsingPeer"` ChaincodeQuery bool `yaml:"chaincodeQuery"` LedgerQuery bool `yaml:"ledgerQuery"` EventSource bool `yaml:"eventSource"` }
PeerClient represents a client for communicating with a peer
type PeerClient struct {
// contains filtered or unexported fields
}
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() (*PeerClient, error)
NewPeerClientFromEnv creates an instance of a PeerClient from the global Viper instance
func (pc *PeerClient) Admin() (pb.AdminClient, error)
Admin returns a client for the Admin service
func (pc *PeerClient) Certificate() tls.Certificate
Certificate returns the TLS client certificate (if available)
func (pc *PeerClient) Deliver() (pb.Deliver_DeliverClient, error)
Deliver returns a client for the Deliver service
func (pc *PeerClient) Endorser() (pb.EndorserClient, error)
Endorser returns a client for the Endorser service
func (pc *PeerClient) PeerDeliver() (api.PeerDeliverClient, error)
PeerDeliver returns a client for the Deliver service for peer-specific use cases (i.e. DeliverFiltered)
PeerConfig defines a peer configuration
type PeerConfig struct { URL string `yaml:"url"` EventURL string `yaml:"eventUrl"` GRPCOptions map[string]interface{} `yaml:"grpcOptions"` TLSCACerts TLSConfig `yaml:"tlsCACerts"` }
PeerDeliverClient holds the necessary information to connect a client to a peer deliver service
type PeerDeliverClient struct { Client pb.DeliverClient }
func (dc PeerDeliverClient) Deliver(ctx context.Context, opts ...grpc.CallOption) (ccapi.Deliver, error)
Deliver connects the client to the Deliver RPC
func (dc PeerDeliverClient) DeliverFiltered(ctx context.Context, opts ...grpc.CallOption) (ccapi.Deliver, error)
DeliverFiltered connects the client to the DeliverFiltered RPC
TLSConfig TLS configurations
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"` }
TLSKeyPair contains the private key and certificate for TLS encryption not currently used by CLI
type TLSKeyPair struct { Key TLSConfig `yaml:"key"` Cert TLSConfig `yaml:"cert"` }
TLSType - not currently used by CLI
type TLSType struct { Enabled bool `yaml:"enabled"` }