Class: Network

fabric-network. Network

A Network represents the set of peers in a Fabric network. Applications should get a Network instance using the gateway's getNetwork method.

new Network()

Methods


<async> addBlockListener(listenerName, callback [, options])

Create a block event listener
Parameters:
Name Type Argument Description
listenerName String a unique name identifying the listener
callback function the callback called when an event is triggered with signature (error, block)
options module:fabric-network.Network~EventListenerOptions <optional>
Optional. The event listener options
Returns:
Type
module:fabric-network~BlockEventListener

<async> addCommitListener(transactionId, callback [, options] [, eventHub])

Create a commit event listener for this transaction.
Parameters:
Name Type Argument Description
transactionId string The transactionId being watched
callback function This callback will be triggered when a transaction commit event is emitted. It takes parameters of error, transactionId, transaction status and block number
options module:fabric-network.Network~EventListenerOptions <optional>
Optional. The event listener options registrations allowing start and end block numbers.
eventHub ChannelEventHub <optional>
Optional. Used to override the event hub selection
Returns:
Type
module:fabric-network~CommitEventListener

getChannel()

Get the underlying channel object representation of this network.
Returns:
A channel.
Type
Channel

getContract(chaincodeId [, name])

Get an instance of a contract (chaincode) on the current network.
Parameters:
Name Type Argument Description
chaincodeId string the chaincode identifier.
name string <optional>
name of the contract.
Returns:
the contract.
Type
module:fabric-network.Contract

Type Definitions


CheckpointerFactory(channelName, listenerName [, options])

Parameters:
Name Type Argument Description
channelName String the name of the channel the checkpoint exists in
listenerName String the name of the listener being checkpointed
options Object <optional>
Optional. Options to configure behaviour of custom checkpointers i.e. Supplying database connection details
Returns:
Type
BaseCheckpointer

EventListenerOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
checkpointer Object The checkpointer factory and options
Properties
Name Type Argument Description
factory module:fabric-network.Network~CheckpointerFactory The checkpointer factory
options Object <optional>
The checkpoint configuration options
replay boolean <optional>
false event replay and checkpointing on listener
filtered boolean <optional>
false use receive filtered block events or not
unregister boolean <optional>
false unregisters the listener as soon as a single event is received
startBlock number <optional>
the first block to play events from
endBlock number <optional>
the final block to play events from
asArray boolean <optional>
will deliver all of the events in a block to the callback
eventHubConnectWait number <optional>
1000 the number of milliseconds before looking for a new event hub
eventHubConnectTimeout number <optional>
30000 the number of milliseconds before timing out event hub connect