new ChannelPeer(mspid, channel, peer, roles)
Construct a ChannelPeer object with the given Peer and opts.
A channel peer object holds channel based references:
MSP ID of the Organization this peer belongs.
Channel object used to know the channel this peer is interacting.
Peer object used for interacting with the Hyperledger fabric network.
ChannelEventHub object used for listening to block changes on the channel.
List of ChannelPeerRoles to indicate the roles this peer performs on the channel.
The roles this Peer performs on this channel are indicated with is object.
Parameters:
Name | Type | Description |
---|---|---|
mspid |
string | The mspid of the organization this peer belongs. |
channel |
Channel | The Channel instance. |
peer |
Peer | The Peer instance. |
roles |
ChannelPeerRoles | The roles for this peer. |
Methods
-
close()
-
-
getChannelEventHub()
-
Get the channel event hub for this channel peer. The ChannelEventHub instance will be assigned when using the Channel newChannelEventHub() method. When using a common connection profile, the ChannelEventHub will be automatically assigned on the Channel Peers as they are created and added to the channel.
Returns:
- The ChannelEventHub instance associated with this Peer instance.- Type
- ChannelEventHub
-
getMspid()
-
Get the MSP ID.
Returns:
The mspId.- Type
- string
-
getName()
-
Get the name. This is a client-side only identifier for this object.
Returns:
The name of the object- Type
- string
-
getPeer()
-
Get the Peer instance this ChannelPeer represents on the channel.
Returns:
The associated Peer instance.- Type
- Peer
-
getUrl()
-
Get the URL of this object.
Returns:
Get the URL associated with the peer object.- Type
- string
-
isInOrg(mspid)
-
Checks if this peer is in the specified organization. The default is true when the incoming organization name is not defined. The default will be true when this peer does not have the organization name defined.
Parameters:
Name Type Description mspid
string The mspid of the organnization Returns:
If this peer belongs to the organization.- Type
- boolean
-
isInRole()
-
Checks if this peer is in the specified role. The default is true when the incoming role is not defined. The default will be true when this peer does not have the role defined.
Returns:
If this peer has this role.- Type
- boolean
-
sendDiscovery()
-
Wrapper method for the associated peer so this object may be used as a Peer Peer#sendDiscovery
-
sendProposal()
-
Wrapper method for the associated peer so this object may be used as a Peer Peer#sendProposal
-
setRole(role, isIn)
-
Set a role for this peer.
Parameters:
Name Type Description role
string The name of the role isIn
boolean The boolean value of does this peer have this role