Documentation ¶
Index ¶
- type ChainCodeCBE
- type ChaincodeEvent
- type Channel
- type CreateChannelRequest
- type CredentialManager
- type DiscoveryProvider
- type DiscoveryService
- type EventHub
- type EventHubExt
- type EventsClient
- type FabricClient
- type GenesisBlockRequest
- type JoinChannelRequest
- type KeyValueStore
- type Orderer
- type OrgAnchorPeer
- type Peer
- type SelectionProvider
- type SelectionService
- type SignedEnvelope
- type SigningIdentity
- type SigningManager
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 Channel ¶
type Channel interface { txn.Sender txn.ProposalSender Name() string Initialize(data []byte) error IsInitialized() bool LoadConfigUpdateEnvelope(data []byte) error SendInstantiateProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []txn.ProposalProcessor) ([]*txn.TransactionProposalResponse, txn.TransactionID, error) SendUpgradeProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []txn.ProposalProcessor) ([]*txn.TransactionProposalResponse, txn.TransactionID, error) // Network // TODO: Use PeerEndorser 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) // Channel Info GenesisBlock(request *GenesisBlockRequest) (*common.Block, error) JoinChannel(request *JoinChannelRequest) error UpdateChannel() bool IsReadonly() bool // 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(txn.ChaincodeInvokeRequest) ([][]byte, error) QueryBySystemChaincode(request txn.ChaincodeInvokeRequest) ([][]byte, 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 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 txn.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 ¶
DiscoveryService is used to discover eligible peers on specific channel
type EventHub ¶
type EventHub interface { SetPeerAddr(peerURL string, certificate string, serverHostOverride string) IsConnected() bool Connect() error Disconnect() error RegisterChaincodeEvent(ccid string, eventname string, callback func(*ChaincodeEvent)) *ChainCodeCBE UnregisterChaincodeEvent(cbe *ChainCodeCBE) RegisterTxEvent(txnID apitxn.TransactionID, callback func(string, pb.TxValidationCode, error)) UnregisterTxEvent(txnID apitxn.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 FabricClient ¶
type FabricClient interface { NewChannel(name string) (Channel, error) Channel(name string) Channel ExtractChannelConfig(configEnvelope []byte) ([]byte, error) SignChannelConfig(config []byte) (*common.ConfigSignature, error) CreateChannel(request CreateChannelRequest) (txn.TransactionID, error) QueryChannelInfo(name string, peers []Peer) (Channel, error) StateStore() KeyValueStore SigningManager() SigningManager CryptoSuite() bccsp.BCCSP SaveUserToStateStore(user User, skipPersistence bool) error LoadUserFromStateStore(name string) (User, error) InstallChaincode(chaincodeName string, chaincodePath string, chaincodeVersion string, chaincodePackage []byte, targets []Peer) ([]*txn.TransactionProposalResponse, string, error) QueryChannels(peer Peer) (*pb.ChannelQueryResponse, error) QueryInstalledChaincodes(peer Peer) (*pb.ChaincodeQueryResponse, error) UserContext() User SetUserContext(user User) Config() config.Config // TODO: refactor to a fab client config interface NewTxnID() (txn.TransactionID, error) }
FabricClient ...
- Main interaction handler with end user. A client instance provides a handler to interact
- with a network of peers, orderers and optionally member services. An application using the
- SDK may need to interact with multiple networks, each through a separate instance of the Client. *
- Each client when initially created should be initialized with configuration data from the
- consensus service, which includes a list of trusted roots, orderer certificates and IP addresses,
- and a list of peer certificates and IP addresses that it can access. This must be done out of band
- as part of bootstrapping the application environment. It is also the responsibility of the application
- to maintain the configuration of a client as the SDK does not persist this object. *
- Each Client instance can maintain several {@link Channel} instances representing channels and the associated
- private ledgers. * *
type GenesisBlockRequest ¶
type GenesisBlockRequest struct {
TxnID txn.TransactionID
}
GenesisBlockRequest ...
type JoinChannelRequest ¶
type JoinChannelRequest struct { Targets []Peer GenesisBlock *common.Block TxnID txn.TransactionID }
JoinChannelRequest allows a set of peers to transact on a channel on the network
type KeyValueStore ¶
type KeyValueStore interface { /** * Get the value associated with name. * * @param {string} name of the key * @returns {[]byte} */ Value(key string) ([]byte, error) /** * Set the value associated with name. * @param {string} name of the key to save * @param {[]byte} value to save */ SetValue(key string, value []byte) error }
KeyValueStore ... *
- Abstract class for a Key-Value store. The Chain class uses this store
- to save sensitive information such as authenticated user's private keys,
- certificates, etc. *
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 ¶
OrgAnchorPeer contains information about an anchor peer on this channel
type Peer ¶
type Peer interface { txn.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 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 SignedEnvelope ¶
A SignedEnvelope can can be sent to an orderer for broadcasting
type SigningIdentity ¶
SigningIdentity is the identity object that encapsulates the user's private key for signing and the user's enrollment certificate (identity)
type SigningManager ¶
SigningManager signs object with provided key
type User ¶
type User interface { Name() string MspID() string EnrollmentCertificate() []byte PrivateKey() bccsp.Key Roles() []string Identity() ([]byte, error) }
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.