...

Package common

import "github.com/hyperledger/fabric/peer/common"
Overview
Index
Subdirectories

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
Variables
func AddOrdererFlags(cmd *cobra.Command)
func CheckLogLevel(level string) error
func GetAdminClient() (pb.AdminClient, error)
func GetCertificate() (tls.Certificate, error)
func GetDefaultSigner() (msp.SigningIdentity, error)
func GetDeliverClient(address, tlsRootCertFile string) (pb.Deliver_DeliverClient, error)
func GetEndorserClient(address, tlsRootCertFile string) (pb.EndorserClient, error)
func GetMockAdminClient(err error) pb.AdminClient
func GetMockEndorserClient(response *pb.ProposalResponse, err error) pb.EndorserClient
func GetOrdererEndpointOfChain(chainID string, signer msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error)
func GetPeerDeliverClient(address, tlsRootCertFile string) (api.PeerDeliverClient, error)
func InitCmd(cmd *cobra.Command, args []string)
func InitConfig(cmdRoot string) error
func InitCrypto(mspMgrConfigDir, localMSPID, localMSPType string) error
func SetBCCSPKeystorePath()
func SetOrdererEnv(cmd *cobra.Command, args []string)
type BroadcastClient
    func GetBroadcastClient() (BroadcastClient, error)
    func GetMockBroadcastClient(err error) BroadcastClient
type CAConfig
type CCType
type ChannelNetworkConfig
type ClientConfig
type CredentialStoreType
type DeliverClient
    func NewDeliverClientForOrderer(channelID string, bestEffort bool) (*DeliverClient, error)
    func NewDeliverClientForPeer(channelID string, bestEffort bool) (*DeliverClient, error)
    func (d *DeliverClient) Close() error
    func (d *DeliverClient) GetNewestBlock() (*cb.Block, error)
    func (d *DeliverClient) GetOldestBlock() (*cb.Block, error)
    func (d *DeliverClient) GetSpecifiedBlock(num uint64) (*cb.Block, error)
type EnrollCredentials
type LoggingType
type MutualTLSConfig
type NetworkConfig
    func GetConfig(fileName string) (*NetworkConfig, error)
type OrdererClient
    func NewOrdererClientFromEnv() (*OrdererClient, error)
    func (oc *OrdererClient) Broadcast() (ab.AtomicBroadcast_BroadcastClient, error)
    func (oc *OrdererClient) Certificate() tls.Certificate
    func (oc *OrdererClient) Deliver() (ab.AtomicBroadcast_DeliverClient, error)
type OrdererConfig
type OrganizationConfig
type PeerChannelConfig
type PeerClient
    func NewPeerClientForAddress(address, tlsRootCertFile string) (*PeerClient, error)
    func NewPeerClientFromEnv() (*PeerClient, error)
    func (pc *PeerClient) Admin() (pb.AdminClient, error)
    func (pc *PeerClient) Certificate() tls.Certificate
    func (pc *PeerClient) Deliver() (pb.Deliver_DeliverClient, error)
    func (pc *PeerClient) Endorser() (pb.EndorserClient, error)
    func (pc *PeerClient) PeerDeliver() (api.PeerDeliverClient, error)
type PeerConfig
type PeerDeliverClient
    func (dc PeerDeliverClient) Deliver(ctx context.Context, opts ...grpc.CallOption) (ccapi.Deliver, error)
    func (dc PeerDeliverClient) DeliverFiltered(ctx context.Context, opts ...grpc.CallOption) (ccapi.Deliver, error)
type TLSConfig
type TLSKeyPair
type TLSType

Package files

broadcastclient.go common.go deliverclient.go mockclient.go networkconfig.go ordererclient.go ordererenv.go peerclient.go peerdeliverclient.go

Constants

const CmdRoot = "core"

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

const UndefinedParamValue = ""

Variables

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

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 GetAdminClient

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

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/PERR) 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 GetMockAdminClient

func GetMockAdminClient(err error) pb.AdminClient

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 msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error)

GetOrdererEndpointOfChain returns orderer endpoints of given chain

func GetPeerDeliverClient

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

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

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 CAConfig

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"`
}

type CCType

CCType - not currently used by CLI

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

type ChannelNetworkConfig

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"`
}

type ClientConfig

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"`
}

type CredentialStoreType

CredentialStoreType - not currently used by CLI

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

type DeliverClient

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

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

NewDeliverClientForOrderer creates a new DeliverClient from an OrdererClient

func NewDeliverClientForPeer

func NewDeliverClientForPeer(channelID string, 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

EnrollCredentials holds credentials used for enrollment not currently used by CLI

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

type LoggingType

LoggingType not currently used by CLI

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

type MutualTLSConfig

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"`
}

type NetworkConfig

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

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

GetConfig unmarshals the provided connection profile into a network configuration struct

type OrdererClient

OrdererClient represents a client for communicating with an ordering service

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

func NewOrdererClientFromEnv

func NewOrdererClientFromEnv() (*OrdererClient, error)

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

func (*OrdererClient) Broadcast

func (oc *OrdererClient) Broadcast() (ab.AtomicBroadcast_BroadcastClient, error)

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

func (oc *OrdererClient) Deliver() (ab.AtomicBroadcast_DeliverClient, error)

Deliver returns a deliver client for the AtomicBroadcast service

type OrdererConfig

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"`
}

type OrganizationConfig

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"`
}

type PeerChannelConfig

PeerChannelConfig defines the peer capabilities

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

type PeerClient

PeerClient represents a client for communicating with a peer

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

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) Admin

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

Admin returns a client for the Admin service

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() (api.PeerDeliverClient, error)

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

type PeerConfig

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"`
}

type PeerDeliverClient

PeerDeliverClient holds the necessary information to connect a client to a peer deliver service

type PeerDeliverClient struct {
    Client pb.DeliverClient
}

func (PeerDeliverClient) Deliver

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

Deliver connects the client to the Deliver RPC

func (PeerDeliverClient) DeliverFiltered

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

DeliverFiltered connects the client to the DeliverFiltered RPC

type TLSConfig

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"`
}

type TLSKeyPair

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"`
}

type TLSType

TLSType - not currently used by CLI

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

Subdirectories

Name Synopsis
..
api
mock Code generated by counterfeiter.