Class: Channel

Channel

Channels provide data isolation for a set of participating organizations.

A Channel object captures the settings needed to interact with a fabric network in the context of a channel. These settings including the list of participating organizations, represented by instances of Membership Service Providers (MSP), endorsers, and committers.

new Channel(name, client)

Returns a new instance of the Channel class.
Parameters:
Name Type Description
name string Name to identify the channel. This value is used as the identifier of the channel when making channel-aware requests with the fabric, such as invoking chaincodes to endorse transactions. The naming of channels is enforced by the ordering service and must be unique within the fabric network. A channel name in fabric network is subject to a pattern revealed in the configuration setting channel-name-regx-checker.
client Client The Client instance.

Methods


addCommitter(committer, replace)

Add the committer object to the channel object
Parameters:
Name Type Description
committer Committer An instance of the Committer class.
replace boolean If an committer exist with the same name, replace with this one.

addEndorser(endorser, replace)

Add the endorser object to the channel object. A channel object can be optionally configured with a list of endorser objects, which will be used when calling certain methods such as sendInstantiateProposal(), sendUpgradeProposal(), sendTransactionProposal.
Parameters:
Name Type Description
endorser Endorser An instance of the Endorser class
replace boolean If a endorser exist with the same name, replace with this one.

addMsp(msp, replace)

Add a MSP configuration to this channel
Parameters:
Name Type Description
msp MspConfig The MSP configuration to add to this Channel
replace boolean If a MSP config has already been added to this channel then replace it with this new configuration.

close()

Close the service connections of all assigned endorsers, committers, channel event hubs, and channel discovery.

getCommitter(name)

This method will return a Committer instance if assigned to this channel. Endorsers that have been created by the Client#newCommitter method and then added to this channel may be reference by the url if no name was provided in the options during the create.
Parameters:
Name Type Description
name string The name or url of the committer
Returns:
The Committer instance.
Type
Committer

getCommitters( [mspid])

Will return an array of Committer instances that have been assigned to this channel instance. Include a MSPID to only return committers in a specific organization.
Parameters:
Name Type Argument Description
mspid string <optional>
Optional. The mspid of the endorsers to return
Returns:
the list of Committers.
Type
Array.<Committer>

getEndorser(name)

This method will return a Endorser.
Parameters:
Name Type Description
name string The name of the endorser assigned to this channel
Returns:
The Endorser instance
Type
Endorser

getEndorsers( [mspid])

Will return an array of Endorser instances that have been assigned to this channel instance. Include a MSPID to only return endorsers in a specific organization.
Parameters:
Name Type Argument Description
mspid string <optional>
Optional. The mspid of the endorsers to return
Returns:
the list of Endorsers.
Type
Array.<Endorser>

getMsp()

Use this method to get MspConfig object for the id provided.
Returns:
The MSP JSON object
Type
MspConfig

getMspids()

Get an array of msp names (ids) from the MSP's for this channel
Returns:
Array of IDs representing the channel's participating organizations
Type
Array.<string>

newCommit(chaincodeId)

Gets a Commit instance for this channel.
Parameters:
Name Type Description
chaincodeId string

newDiscoveryService(name)

Returns a new DiscoveryService instance
Parameters:
Name Type Description
name string The name of this discovery service.

newEndorsement(chaincodeId)

Gets an Endorsement instance for this channel.
Parameters:
Name Type Description
chaincodeId string

newEventService(name)

Returns a new EventService instance
Parameters:
Name Type Description
name string The name of this event service.

newQuery(chaincodeId)

Gets a Query instance for this channel.
Parameters:
Name Type Description
chaincodeId string

removeCommitter(committer)

Remove the committer object from channel object's list of committers. Closes the committer before removal.
Parameters:
Name Type Description
committer Committer An instance of the Committer class.
Returns:
true if able to remove from the list
Type
boolean

removeEndorser(endorser)

Remove the endorser object in the channel object's list of endorsers. Closes the endorser's endorsement and event service connections.
Parameters:
Name Type Description
endorser Endorser An instance of the Endorser class.
Returns:
true if able to remove from the list
Type
boolean

removeMsp(id)

Remove a MSP from this channel's list.
Parameters:
Name Type Description
id string The id of the MSP to remove
Returns:
true if able to remove from the list
Type
boolean

toString()

return a printable representation of this channel object