Class: Peer

Peer

The Peer class represents a peer in the target blockchain network. The application can send endorsement proposals, and query requests through this class.

new Peer(url, opts)

Construct a Peer object with the given url and opts. A peer object encapsulates the properties of an endorsing peer and the interactions with it via the grpc service API. Peer objects are used by the Client objects to send channel-agnostic requests such as installing chaincode, querying peers for installed chaincodes, etc. They are also used by the Channel objects to send channel-aware requests such as instantiating chaincodes, and invoking transactions.
Parameters:
Name Type Description
url string The URL with format of "grpc(s)://host:port".
opts ConnectionOpts The options for the connection to the peer.
Returns:
The Peer instance.
Type
Peer

Extends

Methods


close()

Close the service connections.

getCharacteristics()

Get this remote endpoints characteristics It's name, url, and connection options are the items that make this instance unique. These items may be useful when debugging issues or validating responses.
Inherited From:
Overrides:

getClientCertHash()

Get the client certificate hash
Inherited From:
Overrides:
Returns:
The hash of the client certificate
Type
Array.<byte>

getName()

Get the name. This is a client-side only identifier for this object.
Inherited From:
Overrides:
Returns:
The name of the object
Type
string

getUrl()

Get the URL of this object.
Inherited From:
Overrides:
Returns:
Get the URL associated with the object.
Type
string

isTLS()

Determine whether or not this remote endpoint uses TLS.
Inherited From:
Overrides:
Returns:
True if this endpoint uses TLS, false otherwise.
Type
boolean

<async> sendDiscovery(request, timeout)

Send an discovery request to this peer.
Parameters:
Name Type Description
request SignedRequest A protobuf encoded byte array of type Proposal
timeout Number A number indicating milliseconds to wait on the response before rejecting the promise with a timeout error. This overrides the default timeout of the Peer instance and the global timeout in the config settings.
Returns:
A Promise for a DiscoveryResponse
Type
Promise

<async> sendProposal(proposal, timeout)

Send an endorsement proposal to an endorser. This is used to call an endorsing peer to execute a chaincode to process a transaction proposal, or runs queries.
Parameters:
Name Type Description
proposal Proposal A protobuf encoded byte array of type Proposal
timeout Number A number indicating milliseconds to wait on the response before rejecting the promise with a timeout error. This overrides the default timeout of the Peer instance and the global timeout in the config settings.
Returns:
A Promise for a ProposalResponse
Type
Promise

setName(name)

Set the name as a client-side only identifier of this object.
Parameters:
Name Type Description
name string
Inherited From:
Overrides:

toString()

return a printable representation of this object
Overrides: