fabric: github.com/hyperledger/fabric/peer/common Index | Files | Directories

package common

import "github.com/hyperledger/fabric/peer/common"

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

Package Files

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

Constants

const CmdRoot = "core"
const UndefinedParamValue = ""

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

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 Uses

func AddOrdererFlags(cmd *cobra.Command)

AddOrdererFlags adds flags for orderer-related commands

func CheckLogLevel Uses

func CheckLogLevel(level string) error

CheckLogLevel checks that a given log level string is valid

func GetAdminClient Uses

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 Uses

func GetCertificate() (tls.Certificate, error)

GetCertificate returns the client's TLS certificate

func GetDefaultSigner Uses

func GetDefaultSigner() (msp.SigningIdentity, error)

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

func GetDeliverClient Uses

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 Uses

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 Uses

func GetMockAdminClient(err error) pb.AdminClient

func GetMockEndorserClient Uses

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

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

func GetOrdererEndpointOfChain Uses

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

GetOrdererEndpointOfChain returns orderer endpoints of given chain

func GetPeerDeliverClient Uses

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 Uses

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

func InitConfig Uses

func InitConfig(cmdRoot string) error

InitConfig initializes viper config

func InitCrypto Uses

func InitCrypto(mspMgrConfigDir, localMSPID, localMSPType string) error

InitCrypto initializes crypto for this peer

func SetBCCSPKeystorePath Uses

func SetBCCSPKeystorePath()

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

func SetOrdererEnv Uses

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

SetOrdererEnv adds orderer-specific settings to the global Viper environment

type BroadcastClient Uses

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

func GetBroadcastClient Uses

func GetBroadcastClient() (BroadcastClient, error)

GetBroadcastClient creates a simple instance of the BroadcastClient interface

func GetMockBroadcastClient Uses

func GetMockBroadcastClient(err error) BroadcastClient

type CAConfig Uses

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 Uses

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

CCType - not currently used by CLI

type ChannelNetworkConfig Uses

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 Uses

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 CredentialStoreType Uses

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 Uses

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

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

func NewDeliverClientForOrderer Uses

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

NewDeliverClientForOrderer creates a new DeliverClient from an OrdererClient

func NewDeliverClientForPeer Uses

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

NewDeliverClientForPeer creates a new DeliverClient from a PeerClient

func (*DeliverClient) Close Uses

func (d *DeliverClient) Close() error

Close closes a deliver client's connection

func (*DeliverClient) GetNewestBlock Uses

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

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

func (*DeliverClient) GetOldestBlock Uses

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

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

func (*DeliverClient) GetSpecifiedBlock Uses

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

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

type EnrollCredentials Uses

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

EnrollCredentials holds credentials used for enrollment not currently used by CLI

type LoggingType Uses

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

LoggingType not currently used by CLI

type MutualTLSConfig Uses

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 Uses

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 Uses

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

GetConfig unmarshals the provided connection profile into a network configuration struct

type OrdererClient Uses

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

OrdererClient represents a client for communicating with an ordering service

func NewOrdererClientFromEnv Uses

func NewOrdererClientFromEnv() (*OrdererClient, error)

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

func (*OrdererClient) Broadcast Uses

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

Broadcast returns a broadcast client for the AtomicBroadcast service

func (*OrdererClient) Certificate Uses

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

Certificate returns the TLS client certificate (if available)

func (*OrdererClient) Deliver Uses

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

Deliver returns a deliver client for the AtomicBroadcast service

type OrdererConfig Uses

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 Uses

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 Uses

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 Uses

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

PeerClient represents a client for communicating with a peer

func NewPeerClientForAddress Uses

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 Uses

func NewPeerClientFromEnv() (*PeerClient, error)

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

func (*PeerClient) Admin Uses

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

Admin returns a client for the Admin service

func (*PeerClient) Certificate Uses

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

Certificate returns the TLS client certificate (if available)

func (*PeerClient) Deliver Uses

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

Deliver returns a client for the Deliver service

func (*PeerClient) Endorser Uses

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

Endorser returns a client for the Endorser service

func (*PeerClient) PeerDeliver Uses

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 Uses

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 PeerDeliverClient Uses

type PeerDeliverClient struct {
    Client pb.DeliverClient
}

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

func (PeerDeliverClient) Deliver Uses

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

Deliver connects the client to the Deliver RPC

func (PeerDeliverClient) DeliverFiltered Uses

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

DeliverFiltered connects the client to the DeliverFiltered RPC

type TLSConfig Uses

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 Uses

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 Uses

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

TLSType - not currently used by CLI

Directories

PathSynopsis
api
mockCode generated by counterfeiter.

Package common imports 32 packages (graph) and is imported by 60 packages. Updated 2019-07-11. Refresh now. Tools for package owners.