channel

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CCProposalType

type CCProposalType int

CCProposalType reflects transitions in the chaincode lifecycle

const (
	Instantiate CCProposalType = iota
	Upgrade
)

Define chaincode proposal 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 New

func New(ctx fab.Context, cfg fab.ChannelCfg) (*Channel, error)

New 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

func (c *Channel) AddOrderer(orderer fab.Orderer) error

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

func (c *Channel) AddPeer(peer fab.Peer) error

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

func (c *Channel) ChannelConfig() (*common.ConfigEnvelope, error)

ChannelConfig queries for the current config block for this channel. This transaction will be made to the orderer. @returns {ConfigEnvelope} Object containing the configuration items. @see /protos/orderer/ab.proto @see /protos/common/configtx.proto

func (*Channel) CreateTransaction

func (c *Channel) CreateTransaction(resps []*fab.TransactionProposalResponse) (*fab.Transaction, error)

CreateTransaction create a transaction with proposal response, following the endorsement policy.

func (*Channel) IsInitialized

func (c *Channel) IsInitialized() bool

IsInitialized ... TODO

func (*Channel) IsReadonly

func (c *Channel) IsReadonly() bool

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

func (c *Channel) MSPManager() msp.MSPManager

MSPManager returns the MSP Manager for this channel

func (*Channel) Name

func (c *Channel) Name() string

Name returns the channel name.

func (*Channel) Orderers

func (c *Channel) Orderers() []fab.Orderer

Orderers gets the orderers of a channel.

func (*Channel) OrganizationUnits

func (c *Channel) OrganizationUnits() ([]string, error)

OrganizationUnits - to get identifier for the organization configured on the channel

func (*Channel) Peers

func (c *Channel) Peers() []fab.Peer

Peers returns the peers of of the channel.

func (*Channel) PrimaryPeer

func (c *Channel) PrimaryPeer() fab.Peer

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

func (c *Channel) QueryBlock(blockNumber int) (*common.Block, error)

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

func (c *Channel) QueryBlockByHash(blockHash []byte) (*common.Block, error)

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 fab.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 fab.ChaincodeInvokeRequest) ([][]byte, error)

QueryBySystemChaincode invokes a chaincode that isn't part of a channel.

TODO: This function's name is confusing - call the normal QueryByChaincode for system chaincode on a channel.

func (*Channel) QueryConfigBlock

func (c *Channel) QueryConfigBlock(peers []fab.Peer, minResponses int) (*common.ConfigEnvelope, error)

QueryConfigBlock returns the current configuration block for the specified channel. If the peer doesn't belong to the channel, return error

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

func (c *Channel) RemoveOrderer(orderer fab.Orderer)

RemoveOrderer removes orderer endpoint from a channel object, this is a local-only operation. orderer: An instance of the Orderer class.

func (*Channel) RemovePeer

func (c *Channel) RemovePeer(peer fab.Peer)

RemovePeer remove a peer endpoint from channel.

func (*Channel) SendInstantiateProposal

func (c *Channel) SendInstantiateProposal(chaincodeName string,
	args [][]byte, chaincodePath string, chaincodeVersion string,
	chaincodePolicy *common.SignaturePolicyEnvelope,
	collConfig []*common.CollectionConfig, targets []fab.ProposalProcessor) ([]*fab.TransactionProposalResponse, fab.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 chaincodePolicy: required - chaincode signature policy collConfig: optional - private data collection configuration

func (*Channel) SendTransaction

func (c *Channel) SendTransaction(tx *fab.Transaction) (*fab.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 fab.ChaincodeInvokeRequest, targets []fab.ProposalProcessor) ([]*fab.TransactionProposalResponse, fab.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 []fab.ProposalProcessor) ([]*fab.TransactionProposalResponse, fab.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

func (c *Channel) SetPrimaryPeer(peer fab.Peer) error

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

func (c *Channel) UpdateChannel() bool

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 Ledger

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

Ledger is a client that provides access to the underlying ledger of a channel.

func NewLedger

func NewLedger(ctx fab.Context, chName string) (*Ledger, error)

NewLedger constructs a Ledger client for the current context and named channel.

func (*Ledger) QueryBlock

func (c *Ledger) QueryBlock(blockNumber int, targets []fab.ProposalProcessor) ([]*common.Block, error)

QueryBlock queries the ledger for Block by block number. This query will be made to specified targets. blockNumber: The number which is the ID of the Block. It returns the block.

func (*Ledger) QueryBlockByHash

func (c *Ledger) QueryBlockByHash(blockHash []byte, targets []fab.ProposalProcessor) ([]*common.Block, error)

QueryBlockByHash queries the ledger for Block by block hash. This query will be made to specified targets. Returns the block.

func (*Ledger) QueryConfigBlock

func (c *Ledger) QueryConfigBlock(peers []fab.Peer, minResponses int) (*common.ConfigEnvelope, error)

QueryConfigBlock returns the current configuration block for the specified channel. If the peer doesn't belong to the channel, return error

func (*Ledger) QueryInfo

func (c *Ledger) QueryInfo(targets []fab.ProposalProcessor) ([]*common.BlockchainInfo, error)

QueryInfo queries for various useful information on the state of the channel (height, known peers).

func (*Ledger) QueryInstantiatedChaincodes

func (c *Ledger) QueryInstantiatedChaincodes(targets []fab.ProposalProcessor) ([]*pb.ChaincodeQueryResponse, error)

QueryInstantiatedChaincodes queries the instantiated chaincodes on this channel. This query will be made to specified targets.

func (*Ledger) QueryTransaction

func (c *Ledger) QueryTransaction(transactionID string, targets []fab.ProposalProcessor) ([]*pb.ProcessedTransaction, error)

QueryTransaction queries the ledger for Transaction by number. This query will be made to specified targets. Returns the ProcessedTransaction information containing the transaction.

Jump to

Keyboard shortcuts

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