Class: Orderer

Orderer

The Orderer class encapsulates the client capabilities to interact with an Orderer node in the target blockchain network. The orderer node exposes two APIs: broadcast() and deliver(). Both are streaming APIs so there's a persistent grpc streaming connection between the client and the orderer where messages are exchanged in both directions. The broadcast() API is for sending transactions to the orderer for processing. The deliver() API is for asking the orderer for information such as channel configurations.

new Orderer(url, opts)

Constructs an Orderer object with the given url and opts. An orderer object encapsulates the properties of an orderer node and the interactions with it via the grpc stream API. Orderer objects are used by the Client objects to broadcast requests for creating and updating channels. They are also used by the Channel objects to broadcast requests for ordering 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 orderer.
Returns:
The Orderer instance.
Type
Orderer

Extends

Methods


close()

Close the service connection.

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> sendBroadcast(envelope, timeout)

Send a Broadcast message to the orderer service.
Parameters:
Name Type Description
envelope Array.<byte> Byte data to be included in the broadcast. This must be a protobuf encoded byte array of the common.Envelope that contains either a ConfigUpdateEnvelope or a Transaction in the payload.data property of the envelope.
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.
Throws:
Returns:
A Promise for a BroadcastResponse object
Type
Promise

<async> sendDeliver(envelope)

Send a Deliver message to the orderer service.
Parameters:
Name Type Description
envelope Array.<byte> Byte data to be included in the broadcast. This must be a protobuf encoded byte array of the common.Envelope that contains a SeekInfo in the payload.data property of the envelope. The header.channelHeader.type must be set to common.HeaderType.DELIVER_SEEK_INFO
Throws:
Returns:
A Promise for a protobuf object of type common.Block. Note that this is NOT the same type of object as the Block returned by the BlockDecoder.decode() method and various other methods. A Block is a pure javascript object, whereas the object returned by this method is a protobuf object that contains accessor methods, getters and setters, and toBuffer() for each property to be used for further manipulating the object and convert to and from byte arrays.
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: