Class: Endorser

Endorser

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

new Endorser(name, client [, mspid])

Construct a Endorser object with the name. A Endorser object encapsulates the properties of an endorsing peer and the interactions with it via the grpc service API. Endorser objects are used by the Client objects to send channel-agnostic requests such as 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. Use the connect method with options to establish a connection with the fabric network endpoint.
Parameters:
Name Type Argument Description
name string The name of this Endorser
client Client The client instance
mspid string <optional>
The mspid (organization) of this Endorser
Returns:
The Endorser instance.
Type
Endorser

Extends

Methods


addChaincode(chaincodeName)

Add a chaincode name or ID to this Peer. This will aid in determining if this peer should be used to endorse. This will primarily be used by the DiscoveryService when adding peers to a channel based on the discovery results
Parameters:
Name Type Description
chaincodeName String

<async> checkConnection( [reset])

Check the connection status
Parameters:
Name Type Argument Default Description
reset boolean <optional>
true Optional, attempt to reconnect if endpoint is not connected
Inherited From:
Overrides:

<async> connect( [endpoint] [, options])

Connects this ServiceEndpoint with the given url and opts. If a connect exist an error will be thrown. The application must disconnect the connection before re-connecting to the service.
Parameters:
Name Type Argument Description
endpoint Endpoint <optional>
Service connection options including the url. When an endpoint is not provided, the setEndpoint() must have been called previously. If setEndpoint was previously call and a endpoint is provided here then it will replace the existing endpoint.
options ConnectionOptions <optional>
Any specific options for this instance of the connection to the peer. These will override options from the endpoint service connection options. Endpoint options and option provided here will replace options from the setEndpoint() if previously called.
Inherited From:
Overrides:

disconnect()

disconnect the service connection.
Inherited From:
Overrides:

hasChaincode(chaincodeName [, maybe])

Check if this peer has the chaincode on it's list. If the list is empty then this peer has not been told of it's chaincodes and therefore might be running the chaincode in question.
Parameters:
Name Type Argument Default Description
chaincodeName String
maybe boolean <optional>
true Optional, default true, if noMaybe is true then this method will return true when the peer does not have any chaincodes on the list.

isConnectable()

Check that this ServiceEndpoint could be connected, even if it has failed a previous attempt.
Inherited From:
Overrides:

isTLS()

Determine whether or not this remote endpoint uses TLS.
Inherited From:
Overrides:
Throws:
if the Service Endpoint has not been connected to an endpoint.
Type
Error
Returns:
True if this endpoint uses TLS, false otherwise.
Type
boolean

<async> resetConnection()

Reset the connection
Inherited From:
Overrides:

sendProposal(signedProposal, 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
signedProposal Envelope A signed proposal envelope that has been signed
timeout Number A number indicating milliseconds to wait on the response before rejecting the promise with a timeout error. This overrides the requestTimeout config connection setting of this instance.
Returns:
A Promise for a Object that is the Protobuf 'protos.ProposalResponse' see fabric-protos/protos/peer/proposal_response.proto
Type
Promise

setEndpoint(endpoint, options)

Use this method to give this service endpoint an endpoint and options that it may connect to at a later time. Use the ServiceEndpoint#connect method without a endpoint or options to connect using the setting provided here.
Parameters:
Name Type Description
endpoint Endpoint Service connection options including the url.
options ConnectionOptions Any specific options for this instance of the connection to the peer. These will override options from the endpoint service connection options.
Inherited From:
Overrides:

toString()

return a printable representation of this object
Inherited From:
Overrides: