apifabclient

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CCPackage

type CCPackage struct {
	Type pb.ChaincodeSpec_Type
	Code []byte
}

CCPackage contains package type and bytes required to create CDS

type ChainCodeCBE

type ChainCodeCBE struct {
	// chaincode id
	CCID string
	// event name regex filter
	EventNameFilter string
	// callback function to invoke on successful filter match
	CallbackFunc func(*ChaincodeEvent)
}

ChainCodeCBE ... *

  • The ChainCodeCBE is used internal to the EventHub to hold chaincode
  • event registration callbacks.

type ChaincodeEvent

type ChaincodeEvent struct {
	ChaincodeID string
	TxID        string
	EventName   string
	Payload     []byte
	ChannelID   string
}

ChaincodeEvent contains the current event data for the event handler

type ChaincodeInvokeRequest

type ChaincodeInvokeRequest struct {
	Targets      []ProposalProcessor // TODO: remove
	ChaincodeID  string
	TransientMap map[string][]byte
	Fcn          string
	Args         [][]byte
}

ChaincodeInvokeRequest contains the parameters for sending a transaction proposal.

type Channel

type Channel interface {
	Sender
	ProposalSender

	Name() string
	ChannelConfig() (*common.ConfigEnvelope, error)

	SendInstantiateProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope,
		collConfig []*common.CollectionConfig, targets []ProposalProcessor) ([]*TransactionProposalResponse, TransactionID, error)
	SendUpgradeProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []ProposalProcessor) ([]*TransactionProposalResponse, TransactionID, error)

	// Network
	// Deprecated: getters/setters are deprecated from interface.
	AddPeer(peer Peer) error
	RemovePeer(peer Peer)
	Peers() []Peer
	AnchorPeers() []OrgAnchorPeer
	SetPrimaryPeer(peer Peer) error
	PrimaryPeer() Peer
	AddOrderer(orderer Orderer) error
	RemoveOrderer(orderer Orderer)
	Orderers() []Orderer
	SetMSPManager(mspManager msp.MSPManager)
	MSPManager() msp.MSPManager
	OrganizationUnits() ([]string, error)

	// Query
	QueryInfo() (*common.BlockchainInfo, error)
	QueryBlock(blockNumber int) (*common.Block, error)
	QueryBlockByHash(blockHash []byte) (*common.Block, error)
	QueryTransaction(transactionID string) (*pb.ProcessedTransaction, error)
	QueryInstantiatedChaincodes() (*pb.ChaincodeQueryResponse, error)
	QueryByChaincode(ChaincodeInvokeRequest) ([][]byte, error)
	QueryBySystemChaincode(request ChaincodeInvokeRequest) ([][]byte, error)
	QueryConfigBlock(peers []Peer, minResponses int) (*common.ConfigEnvelope, error)
}

Channel ... *

  • Channel representing a Channel with which the client SDK interacts. *
  • The Channel object captures settings for a channel, which is created by
  • the orderers to isolate transactions delivery to peers participating on channel.
  • A channel must be initialized after it has been configured with the list of peers
  • and orderers. The initialization sends a get configuration block request to the
  • primary orderer to retrieve the configuration settings for this channel.

type ChannelCfg

type ChannelCfg interface {
	Name() string
	Msps() []*msp.MSPConfig
	AnchorPeers() []*OrgAnchorPeer
	Orderers() []string
	Versions() *Versions
}

ChannelCfg contains channel configuration

type ChannelConfig

type ChannelConfig interface {

	// Query channel configuration
	Query() (ChannelCfg, error)
}

ChannelConfig allows for interaction with peer regarding channel configuration

type ChannelLedger

type ChannelLedger interface {
	QueryInfo(targets []ProposalProcessor) ([]*common.BlockchainInfo, error)
	QueryBlock(blockNumber int, targets []ProposalProcessor) ([]*common.Block, error)
	QueryBlockByHash(blockHash []byte, targets []ProposalProcessor) ([]*common.Block, error)
	QueryTransaction(transactionID string, targets []ProposalProcessor) ([]*pb.ProcessedTransaction, error)
	QueryInstantiatedChaincodes(targets []ProposalProcessor) ([]*pb.ChaincodeQueryResponse, error)
}

ChannelLedger provides access to the underlying ledger for a channel.

type ChannelProvider

type ChannelProvider interface {
	NewChannelService(ic IdentityContext, channelID string) (ChannelService, error)
}

ChannelProvider supplies Channel related-objects for the named channel.

type ChannelService

type ChannelService interface {
	Config() (ChannelConfig, error)
	Ledger() (ChannelLedger, error)
	Channel() (Channel, error)
	EventHub() (EventHub, error) // TODO support new event delivery
}

ChannelService supplies services related to a channel.

type Context

type Context interface {
	ProviderContext
	IdentityContext
}

Context supplies the configuration and signing identity to client objects.

type CreateChannelRequest

type CreateChannelRequest struct {
	// required - The name of the new channel
	Name string
	// required - The Orderer to send the update request
	Orderer Orderer
	// optional - the envelope object containing all
	// required settings and signatures to initialize this channel.
	// This envelope would have been created by the command
	// line tool "configtx"
	Envelope []byte
	// optional - ConfigUpdate object built by the
	// buildChannelConfig() method of this package
	Config []byte
	// optional - the list of collected signatures
	// required by the channel create policy when using the `config` parameter.
	// see signChannelConfig() method of this package
	Signatures []*common.ConfigSignature

	// TODO: InvokeChannelRequest allows the TransactionID to be passed in.
	// This request struct also has the field for consistency but perhaps it should be removed.
	TxnID TransactionID
}

CreateChannelRequest requests channel creation on the network

type CredentialManager

type CredentialManager interface {
	GetSigningIdentity(name string) (*SigningIdentity, error)
}

CredentialManager retrieves user's signing identity

type DiscoveryProvider

type DiscoveryProvider interface {
	NewDiscoveryService(channelID string) (DiscoveryService, error)
}

DiscoveryProvider is used to discover peers on the network

type DiscoveryService

type DiscoveryService interface {
	GetPeers() ([]Peer, error)
}

DiscoveryService is used to discover eligible peers on specific channel

type EventHub

type EventHub interface {
	SetPeerAddr(peerURL string, certificate *sm2.Certificate, serverHostOverride string)
	IsConnected() bool
	Connect() error
	Disconnect() error
	RegisterChaincodeEvent(ccid string, eventname string, callback func(*ChaincodeEvent)) *ChainCodeCBE
	UnregisterChaincodeEvent(cbe *ChainCodeCBE)
	RegisterTxEvent(txnID TransactionID, callback func(string, pb.TxValidationCode, error))
	UnregisterTxEvent(txnID TransactionID)
	RegisterBlockEvent(callback func(*common.Block))
	UnregisterBlockEvent(callback func(*common.Block))
}

EventHub ...

type EventHubExt

type EventHubExt interface {
	SetInterests(block bool)
}

The EventHubExt interface allows extensions of the SDK to add functionality to EventHub overloads.

type EventsClient

type EventsClient interface {
	RegisterAsync(ies []*ehpb.Interest) error
	UnregisterAsync(ies []*ehpb.Interest) error
	Unregister(ies []*ehpb.Interest) error
	Recv() (*ehpb.Event, error)
	Start() error
	Stop() error
}

EventsClient holds the stream and adapter for consumer to work with

type IdentityContext

type IdentityContext interface {
	MspID() string
	Identity() ([]byte, error)
	PrivateKey() apicryptosuite.Key
}

IdentityContext supplies the serialized identity and key reference.

TODO - refactor SigningIdentity and this interface.

type InstallChaincodeRequest

type InstallChaincodeRequest struct {
	// required - name of the chaincode
	Name string
	// required - path to the location of chaincode sources (path from GOPATH/src folder)
	Path string
	// chaincodeVersion: required - version of the chaincode
	Version string
	// required - package (chaincode package type and bytes)
	Package *CCPackage
	// required - proposal processor list
	Targets []ProposalProcessor
}

InstallChaincodeRequest requests chaincode installation on the network

type JoinChannelRequest

type JoinChannelRequest struct {
	// The name of the channel to be joined.
	Name         string
	GenesisBlock *common.Block
	Targets      []ProposalProcessor
}

JoinChannelRequest allows a set of peers to transact on a channel on the network

type Orderer

type Orderer interface {
	URL() string
	SendBroadcast(envelope *SignedEnvelope) (*common.Status, error)
	SendDeliver(envelope *SignedEnvelope) (chan *common.Block, chan error)
}

Orderer The Orderer class represents a peer in the target blockchain network to which HFC sends a block of transactions of endorsed proposals requiring ordering.

type OrgAnchorPeer

type OrgAnchorPeer struct {
	Org  string
	Host string
	Port int32
}

OrgAnchorPeer contains information about an anchor peer on this channel

type Peer

type Peer interface {
	ProposalProcessor

	// ECert Client (need verb)
	EnrollmentCertificate() *pem.Block
	SetEnrollmentCertificate(pem *pem.Block)

	// Peer Properties
	Name() string
	SetName(name string)
	// MSPID gets the Peer mspID.
	MSPID() string
	// SetMSPID sets the Peer mspID.
	SetMSPID(mspID string)
	Roles() []string
	SetRoles(roles []string)
	URL() string
}

The Peer class represents a peer in the target blockchain network to which HFC sends endorsement proposals, transaction ordering or query requests.

The Peer class represents the remote Peer node and its network membership materials, aka the ECert used to verify signatures. Peer membership represents organizations, unlike User membership which represents individuals.

When constructed, a Peer instance can be designated as an event source, in which case a “eventSourceUrl” attribute should be configured. This allows the SDK to automatically attach transaction event listeners to the event stream.

It should be noted that Peer event streams function at the Peer level and not at the channel and chaincode levels.

type ProposalProcessor

type ProposalProcessor interface {
	ProcessTransactionProposal(proposal TransactionProposal) (TransactionProposalResponse, error)
}

ProposalProcessor simulates transaction proposal, so that a client can submit the result for ordering.

type ProposalSender

type ProposalSender interface {
	SendTransactionProposal(ChaincodeInvokeRequest, []ProposalProcessor) ([]*TransactionProposalResponse, TransactionID, error)
}

ProposalSender provides the ability for a transaction proposal to be created and sent.

type ProviderContext

type ProviderContext interface {
	SigningManager() SigningManager
	Config() config.Config
	CryptoSuite() apicryptosuite.CryptoSuite
}

ProviderContext supplies the configuration to client objects.

type Resource

type Resource interface {
	CreateChannel(request CreateChannelRequest) (TransactionID, error)
	InstallChaincode(request InstallChaincodeRequest) ([]*TransactionProposalResponse, string, error)
	QueryInstalledChaincodes(peer ProposalProcessor) (*pb.ChaincodeQueryResponse, error)
	QueryChannels(peer ProposalProcessor) (*pb.ChannelQueryResponse, error)

	GenesisBlockFromOrderer(channelName string, orderer Orderer) (*common.Block, error)
	JoinChannel(request JoinChannelRequest) error

	// TODO - the following methods are utilities
	ExtractChannelConfig(configEnvelope []byte) ([]byte, error)
	SignChannelConfig(config []byte, signer IdentityContext) (*common.ConfigSignature, error)
}

Resource is a client that provides access to fabric resources such as chaincode.

type SelectionProvider

type SelectionProvider interface {
	NewSelectionService(channelID string) (SelectionService, error)
}

SelectionProvider is used to select peers for endorsement

type SelectionService

type SelectionService interface {
	// GetEndorsersForChaincode returns a set of peers that should satisfy the endorsement
	// policies of all of the given chaincodes
	GetEndorsersForChaincode(channelPeers []Peer, chaincodeIDs ...string) ([]Peer, error)
}

SelectionService selects peers for endorsement and commit events

type Sender

type Sender interface {
	CreateTransaction(resps []*TransactionProposalResponse) (*Transaction, error)
	SendTransaction(tx *Transaction) (*TransactionResponse, error)
}

Sender provides the ability for a transaction to be created and sent.

type SignedEnvelope

type SignedEnvelope struct {
	Payload   []byte
	Signature []byte
}

A SignedEnvelope can can be sent to an orderer for broadcasting

type SigningIdentity

type SigningIdentity struct {
	MspID          string
	EnrollmentCert []byte
	PrivateKey     apicryptosuite.Key
}

SigningIdentity is the identity object that encapsulates the user's private key for signing and the user's enrollment certificate (identity)

type SigningManager

type SigningManager interface {
	Sign([]byte, apicryptosuite.Key) ([]byte, error)
}

SigningManager signs object with provided key

type TargetFilter

type TargetFilter interface {
	// Accept returns true if peer should be included in the list of target peers
	Accept(peer Peer) bool
}

TargetFilter allows for filtering target peers

type Transaction

type Transaction struct {
	Proposal    *TransactionProposal
	Transaction *pb.Transaction
}

The Transaction object created from an endorsed proposal.

type TransactionID

type TransactionID struct {
	ID    string
	Nonce []byte
}

TransactionID contains the ID of a Fabric Transaction Proposal

type TransactionProposal

type TransactionProposal struct {
	TxnID TransactionID

	SignedProposal *pb.SignedProposal
	Proposal       *pb.Proposal
}

TransactionProposal requests simulation of a proposed transaction from transaction processors.

type TransactionProposalResponse

type TransactionProposalResponse struct {
	Endorser string
	Status   int32

	Proposal         TransactionProposal
	ProposalResponse *pb.ProposalResponse
}

TransactionProposalResponse respresents the result of transaction proposal processing.

type TransactionResponse

type TransactionResponse struct {
	Orderer string
	Err     error
}

TransactionResponse contains information returned by the orderer.

type User

type User interface {
	IdentityContext

	Name() string
	EnrollmentCertificate() []byte
	Roles() []string
}

User represents users that have been enrolled and represented by an enrollment certificate (ECert) and a signing key. The ECert must have been signed by one of the CAs the blockchain network has been configured to trust. An enrolled user (having a signing key and ECert) can conduct chaincode deployments, transactions and queries with the Chain.

User ECerts can be obtained from a CA beforehand as part of deploying the application, or it can be obtained from the optional Fabric COP service via its enrollment process.

Sometimes User identities are confused with Peer identities. User identities represent signing capability because it has access to the private key, while Peer identities in the context of the application/SDK only has the certificate for verifying signatures. An application cannot use the Peer identity to sign things because the application doesn’t have access to the Peer identity’s private key.

type Versions

type Versions struct {
	ReadSet  *common.ConfigGroup
	WriteSet *common.ConfigGroup
	Channel  *common.ConfigGroup
}

Versions ...

Directories

Path Synopsis
Package mock_apifabclient is a generated GoMock package.
Package mock_apifabclient is a generated GoMock package.

Jump to

Keyboard shortcuts

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