src/main/java/org/hyperledger/fabric/sdk/Channel.java
/**
     * Add a peer to the channel
     *
     * @param peer        The Peer to add.
     * @param peerOptions see {@link PeerRole}
     * @return Channel The current channel added.
     * @throws InvalidArgumentException
     */
Add a peer to the channel
@param peer        The Peer to add.
@param peerOptions see  PeerRole
@return Channel The current channel added.
Add a peer to the channel @param peer The Peer to add . @param peerOptions see PeerRole @return Channel The current channel added .
public Channel addPeer(Peer peer, PeerOptions peerOptions) throws InvalidArgumentException {
        if (shutdown) {
            throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
        }
        if (initialized) {
            throw new InvalidArgumentException(format("Channel %s has been initialized.", name));
        }
        if (null == peer) {
            throw new InvalidArgumentException("Peer is invalid can not be null.");
        }
        if (peer.getChannel() != null && peer.getChannel() != this) {
            throw new InvalidArgumentException(format("Peer already connected to channel %s", peer.getChannel().getName()));
        }
        if (null == peerOptions) {
            throw new InvalidArgumentException("Peer is invalid can not be null.");
        }
        peer.setChannel(this);
        peers.add(peer);
        peerOptionsMap.put(peer, peerOptions.clone());
        for (Map.Entry<PeerRole, Set<Peer>> peerRole : peerRoleSetMap.entrySet()) {
            if (peerOptions.getPeerRoles().contains(peerRole.getKey())) {
                peerRole.getValue().add(peer);
            }
        }
        return this;
    }
public Channel addPeer ( Peer peer , PeerOptions peerOptions ) throws InvalidArgumentException { if ( shutdown ) { throw new InvalidArgumentException ( format ( "Channel %s has been shutdown." , name ) ) ; } if ( initialized ) { throw new InvalidArgumentException ( format ( "Channel %s has been initialized." , name ) ) ; } if ( null == peer ) { throw new InvalidArgumentException ( "Peer is invalid can not be null." ) ; } if ( peer . getChannel ( ) != null && peer . getChannel ( ) != this ) { throw new InvalidArgumentException ( format ( "Peer already connected to channel %s" , peer . getChannel ( ) . getName ( ) ) ) ; } if ( null == peerOptions ) { throw new InvalidArgumentException ( "Peer is invalid can not be null." ) ; } peer . setChannel ( this ) ; peers . add ( peer ) ; peerOptionsMap . put ( peer , peerOptions . clone ( ) ) ; for ( Map . Entry < PeerRole , Set < Peer > > peerRole : peerRoleSetMap . entrySet ( ) ) { if ( peerOptions . getPeerRoles ( ) . contains ( peerRole . getKey ( ) ) ) { peerRole . getValue ( ) . add ( peer ) ; } } return this ; }
Add a peer to the channel
 @param peer        The Peer to add.
Add a peer to the channel @param peer The Peer to add .