Documentation ¶
Index ¶
- func BuildChannelHeader(headerType common.HeaderType, channelID string, txID string, epoch uint64, ...) (*common.ChannelHeader, error)
- func QueryBySystemChaincode(request txn.ChaincodeInvokeRequest, clientContext ClientContext) ([][]byte, error)
- func SendTransactionProposalWithChannelID(channelID string, request apitxn.ChaincodeInvokeRequest, ...) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
- type Channel
- func (c *Channel) AddOrderer(orderer fab.Orderer) error
- func (c *Channel) AddPeer(peer fab.Peer) error
- func (c *Channel) AnchorPeers() []fab.OrgAnchorPeer
- func (c *Channel) BroadcastEnvelope(envelope *fab.SignedEnvelope) (*apitxn.TransactionResponse, error)
- func (c *Channel) ClientContext() ClientContext
- func (c *Channel) CreateTransaction(resps []*apitxn.TransactionProposalResponse) (*apitxn.Transaction, error)
- func (c *Channel) GenesisBlock(request *fab.GenesisBlockRequest) (*common.Block, error)
- func (c *Channel) Initialize(configUpdate []byte) error
- func (c *Channel) IsInitialized() bool
- func (c *Channel) IsReadonly() bool
- func (c *Channel) JoinChannel(request *fab.JoinChannelRequest) error
- func (c *Channel) LoadConfigUpdateEnvelope(data []byte) error
- func (c *Channel) MSPManager() msp.MSPManager
- func (c *Channel) Name() string
- func (c *Channel) Orderers() []fab.Orderer
- func (c *Channel) OrganizationUnits() ([]string, error)
- func (c *Channel) Peers() []fab.Peer
- func (c *Channel) PrimaryPeer() fab.Peer
- func (c *Channel) ProposalBytes(tp *apitxn.TransactionProposal) ([]byte, error)
- func (c *Channel) QueryBlock(blockNumber int) (*common.Block, error)
- func (c *Channel) QueryBlockByHash(blockHash []byte) (*common.Block, error)
- func (c *Channel) QueryByChaincode(request txn.ChaincodeInvokeRequest) ([][]byte, error)
- func (c *Channel) QueryBySystemChaincode(request txn.ChaincodeInvokeRequest) ([][]byte, error)
- func (c *Channel) QueryInfo() (*common.BlockchainInfo, error)
- func (c *Channel) QueryInstantiatedChaincodes() (*pb.ChaincodeQueryResponse, error)
- func (c *Channel) QueryTransaction(transactionID string) (*pb.ProcessedTransaction, error)
- func (c *Channel) RemoveOrderer(orderer fab.Orderer)
- func (c *Channel) RemovePeer(peer fab.Peer)
- func (c *Channel) SendEnvelope(envelope *fab.SignedEnvelope) (*common.Block, error)
- func (c *Channel) SendInstantiateProposal(chaincodeName string, args [][]byte, chaincodePath string, ...) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
- func (c *Channel) SendTransaction(tx *apitxn.Transaction) (*apitxn.TransactionResponse, error)
- func (c *Channel) SendTransactionProposal(request apitxn.ChaincodeInvokeRequest) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
- func (c *Channel) SendUpgradeProposal(chaincodeName string, args [][]byte, chaincodePath string, ...) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
- func (c *Channel) SetMSPManager(mspManager msp.MSPManager)
- func (c *Channel) SetPrimaryPeer(peer fab.Peer) error
- func (c *Channel) SignPayload(payload []byte) (*fab.SignedEnvelope, error)
- func (c *Channel) UpdateChannel() bool
- type ClientContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildChannelHeader ¶
func BuildChannelHeader(headerType common.HeaderType, channelID string, txID string, epoch uint64, chaincodeID string, timestamp time.Time) (*common.ChannelHeader, error)
BuildChannelHeader is a utility method to build a common chain header (TODO refactor)
func QueryBySystemChaincode ¶
func QueryBySystemChaincode(request txn.ChaincodeInvokeRequest, clientContext ClientContext) ([][]byte, error)
QueryBySystemChaincode invokes a system chaincode TODO - should be moved.
func SendTransactionProposalWithChannelID ¶
func SendTransactionProposalWithChannelID(channelID string, request apitxn.ChaincodeInvokeRequest, clientContext ClientContext) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
SendTransactionProposalWithChannelID sends the created proposal to peer for endorsement. TODO: return the entire request or just the txn ID?
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel captures settings for a channel, which is created by the orderers to isolate transactions delivery to peers participating on channel.
func NewChannel ¶
func NewChannel(name string, client fab.FabricClient) (*Channel, error)
NewChannel represents a channel in a Fabric network. name: used to identify different channel instances. The naming of channel instances is enforced by the ordering service and must be unique within the blockchain network. client: Provides operational context such as submitting User etc.
func (*Channel) AddOrderer ¶
AddOrderer adds an orderer endpoint to a channel object, this is a local-only operation. A channel instance may choose to use a single orderer node, which will broadcast requests to the rest of the orderer network. Or if the application does not trust the orderer nodes, it can choose to use more than one by adding them to the channel instance. All APIs concerning the orderer will broadcast to all orderers simultaneously. orderer: An instance of the Orderer interface. Returns error if the orderer with that url already exists.
func (*Channel) AddPeer ¶
AddPeer adds a peer endpoint to channel. It returns error if the peer with that url already exists.
func (*Channel) AnchorPeers ¶
func (c *Channel) AnchorPeers() []fab.OrgAnchorPeer
AnchorPeers returns the anchor peers for this channel. Note: channel.Initialize() must be called first to retrieve anchor peers
func (*Channel) BroadcastEnvelope ¶
func (c *Channel) BroadcastEnvelope(envelope *fab.SignedEnvelope) (*apitxn.TransactionResponse, error)
BroadcastEnvelope will send the given envelope to some orderer, picking random endpoints until all are exhausted
func (*Channel) ClientContext ¶
func (c *Channel) ClientContext() ClientContext
ClientContext returns the Client that was passed in to NewChannel
func (*Channel) CreateTransaction ¶
func (c *Channel) CreateTransaction(resps []*apitxn.TransactionProposalResponse) (*apitxn.Transaction, error)
CreateTransaction create a transaction with proposal response, following the endorsement policy.
func (*Channel) GenesisBlock ¶
GenesisBlock returns the genesis block from the defined orderer that may be used in a join request request: An object containing the following fields:
`txId` : required - String of the transaction id `nonce` : required - Integer of the once time number
See /protos/peer/proposal_response.proto
func (*Channel) Initialize ¶
Initialize initializes the channel. Retrieves the configuration from the primary orderer and initializes this channel with those values. Optionally a configuration may be passed in to initialize this channel without making the call to the orderer. config_update: Optional - A serialized form of the protobuf configuration update.
func (*Channel) IsReadonly ¶
IsReadonly gets channel status to see if the underlying channel has been terminated, making it a read-only channel, where information (transactions and states) can be queried but no new transactions can be submitted. It returns read-only, true or not.
func (*Channel) JoinChannel ¶
func (c *Channel) JoinChannel(request *fab.JoinChannelRequest) error
JoinChannel sends a join channel proposal to one or more endorsing peers Will get the genesis block from the defined orderer to be used in the proposal. request: An object containing the following fields: `targets` : required - An array of `Peer` objects that will join
this channel
`block` : the genesis block of the channel
see GenesisBlock() method
`txId` : required - String of the transaction id `nonce` : required - Integer of the once time number See /protos/peer/proposal_response.proto
func (*Channel) LoadConfigUpdateEnvelope ¶
LoadConfigUpdateEnvelope is a utility method to load this channel with configuration information from an Envelope that contains a Configuration. data: the envelope with the configuration update items. See /protos/common/configtx.proto
func (*Channel) MSPManager ¶
func (c *Channel) MSPManager() msp.MSPManager
MSPManager returns the MSP Manager for this channel
func (*Channel) OrganizationUnits ¶
OrganizationUnits - to get identifier for the organization configured on the channel
func (*Channel) PrimaryPeer ¶
PrimaryPeer gets the primary peer -- the peer to use for doing queries. Default: When no primary peer has been set the first peer from map range will be used.
func (*Channel) ProposalBytes ¶
func (c *Channel) ProposalBytes(tp *apitxn.TransactionProposal) ([]byte, error)
ProposalBytes returns the serialized transaction.
func (*Channel) QueryBlock ¶
QueryBlock queries the ledger for Block by block number. This query will be made to the primary peer. blockNumber: The number which is the ID of the Block. It returns the block.
func (*Channel) QueryBlockByHash ¶
QueryBlockByHash queries the ledger for Block by block hash. This query will be made to the primary peer. Returns the block.
func (*Channel) QueryByChaincode ¶
func (c *Channel) QueryByChaincode(request txn.ChaincodeInvokeRequest) ([][]byte, error)
QueryByChaincode sends a proposal to one or more endorsing peers that will be handled by the chaincode. This request will be presented to the chaincode 'invoke' and must understand from the arguments that this is a query request. The chaincode must also return results in the byte array format and the caller will have to be able to decode. these results.
func (*Channel) QueryBySystemChaincode ¶
func (c *Channel) QueryBySystemChaincode(request txn.ChaincodeInvokeRequest) ([][]byte, error)
QueryBySystemChaincode invokes a system chaincode
func (*Channel) QueryInfo ¶
func (c *Channel) QueryInfo() (*common.BlockchainInfo, error)
QueryInfo queries for various useful information on the state of the channel (height, known peers). This query will be made to the primary peer.
func (*Channel) QueryInstantiatedChaincodes ¶
func (c *Channel) QueryInstantiatedChaincodes() (*pb.ChaincodeQueryResponse, error)
QueryInstantiatedChaincodes queries the instantiated chaincodes on this channel. This query will be made to the primary peer.
func (*Channel) QueryTransaction ¶
func (c *Channel) QueryTransaction(transactionID string) (*pb.ProcessedTransaction, error)
QueryTransaction queries the ledger for Transaction by number. This query will be made to the primary peer. Returns the ProcessedTransaction information containing the transaction. TODO: add optional target
func (*Channel) RemoveOrderer ¶
RemoveOrderer removes orderer endpoint from a channel object, this is a local-only operation. orderer: An instance of the Orderer class.
func (*Channel) RemovePeer ¶
RemovePeer remove a peer endpoint from channel.
func (*Channel) SendEnvelope ¶
SendEnvelope sends the given envelope to each orderer and returns a block response
func (*Channel) SendInstantiateProposal ¶
func (c *Channel) SendInstantiateProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []apitxn.ProposalProcessor) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
SendInstantiateProposal sends an instantiate proposal to one or more endorsing peers. chaincodeName: required - The name of the chain. args: optional - string Array arguments specific to the chaincode being instantiated chaincodePath: required - string of the path to the location of the source code of the chaincode chaincodeVersion: required - string of the version of the chaincode
func (*Channel) SendTransaction ¶
func (c *Channel) SendTransaction(tx *apitxn.Transaction) (*apitxn.TransactionResponse, error)
SendTransaction send a transaction to the chain’s orderer service (one or more orderer endpoints) for consensus and committing to the ledger.
func (*Channel) SendTransactionProposal ¶
func (c *Channel) SendTransactionProposal(request apitxn.ChaincodeInvokeRequest) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
SendTransactionProposal sends the created proposal to peer for endorsement. TODO: return the entire request or just the txn ID?
func (*Channel) SendUpgradeProposal ¶
func (c *Channel) SendUpgradeProposal(chaincodeName string, args [][]byte, chaincodePath string, chaincodeVersion string, chaincodePolicy *common.SignaturePolicyEnvelope, targets []apitxn.ProposalProcessor) ([]*apitxn.TransactionProposalResponse, apitxn.TransactionID, error)
SendUpgradeProposal sends an upgrade proposal to one or more endorsing peers. chaincodeName: required - The name of the chain. args: optional - string Array arguments specific to the chaincode being upgraded chaincodePath: required - string of the path to the location of the source code of the chaincode chaincodeVersion: required - string of the version of the chaincode
func (*Channel) SetMSPManager ¶
func (c *Channel) SetMSPManager(mspManager msp.MSPManager)
SetMSPManager sets the MSP Manager for this channel. This utility method will not normally be used as the "Initialize()" method will read this channel's current configuration and reset the MSPManager with the MSP's found.
func (*Channel) SetPrimaryPeer ¶
SetPrimaryPeer sets the primary peer -- The peer to use for doing queries. Peer must be a peer on this channel's peer list. Default: When no primary peer has been set the first peer on the list will be used. It returns error when peer is not on the existing peer list
func (*Channel) SignPayload ¶
func (c *Channel) SignPayload(payload []byte) (*fab.SignedEnvelope, error)
SignPayload ... TODO.
func (*Channel) UpdateChannel ¶
UpdateChannel calls the orderer(s) to update an existing channel. This allows the addition and deletion of Peer nodes to an existing channel, as well as the update of Peer certificate information upon certificate renewals. It returns whether or not the channel update process was successful.
type ClientContext ¶
type ClientContext interface { UserContext() fab.User SigningManager() fab.SigningManager NewTxnID() (apitxn.TransactionID, error) Config() config.Config }
ClientContext ...