new Gateway()
Methods
-
<async> connect(config, options)
-
Connect to the Gateway with a connection profile or a prebuilt Client instance.
Parameters:
Name Type Description configstring | object | Client The configuration for this Gateway which can be: - A fully qualified common connection profile file path (String)
- A common connection profile JSON (Object)
- A pre-configured client instance
optionsmodule:fabric-network.Gateway~GatewayOptions specific options for creating this Gateway instance Example
const gateway = new Gateway(); const wallet = new FileSystemWallet('./WALLETS/wallet'); const ccpFile = fs.readFileSync('./network.json'); const ccp = JSON.parse(ccpFile.toString()); await gateway.connect(ccp, { identity: 'admin', wallet: wallet }); -
disconnect()
-
Clean up and disconnect this Gateway connection in preparation for it to be discarded and garbage collected
-
getClient()
-
Get the underlying Client object instance
Returns:
The underlying client instance- Type
- Client
-
getCurrentIdentity()
-
Get the current identity
Returns:
The current identity used by this Gateway.- Type
- User
-
<async> getNetwork(networkName)
-
Returns an object representing a network
Parameters:
Name Type Description networkNamestring The name of the network (channel name) Returns:
-
getOptions()
-
Returns the set of options associated with the Gateway connection
Returns:
The Gateway connection options
Type Definitions
-
AbstractEventHubSelectionStrategy
-
Type:
- Object
Properties:
Name Type Description getNextPeerfunction Function that returns the next peer in the list of available peers updateEventHubAvailabilityfunction Function that updates the availability of an event hub -
DefaultEventHandlerOptions
-
Type:
- Object
Properties:
Name Type Argument Default Description commitTimeoutnumber <optional>
300 The timeout period in seconds to wait for commit notification to complete. endorseTimeoutnumber <optional>
45 The timeout period in seconds to wait for the endorsement to complete. strategymodule:fabric-network.Gateway~TxEventHandlerFactory <optional>
<nullable>
MSPID_SCOPE_ALLFORTX Event handling strategy to identify successful transaction commits. A null value indicates that no event handling is desired. The default is MSPID_SCOPE_ALLFORTX. -
DefaultEventHubSelectionFactory
-
Type:
- Object
-
DefaultEventHubSelectionOptions
-
Type:
- Object
Properties:
Name Type Argument Default Description strategymodule:fabric-network.Gateway~DefaultEventHubSelectionFactory <optional>
<nullable>
MSPID_SCOPE_ROUND_ROBIN Selects the next event hub in the event of a new listener being created or an event hub disconnect -
DiscoveryOptions
-
Type:
- Object
Properties:
Name Type Argument Default Description enabledboolean <optional>
true True if discovery should be used; otherwise false. asLocalhostboolean <optional>
false Convert discovered host addresses to be 'localhost'. Will be needed when running a docker composed fabric network on the local system; otherwise should be disabled. -
GatewayOptions
-
Type:
- Object
Properties:
Name Type Argument Description walletmodule:fabric-network.Wallet The identity wallet implementation for use with this Gateway instance. identitystring The identity in the wallet for all interactions on this Gateway instance. clientTlsIdentitystring <optional>
The identity in the wallet to use as the client TLS identity. eventHandlerOptionsmodule:fabric-network.Gateway~DefaultEventHandlerOptions <optional>
Options for the inbuilt default event handler capability. queryHandlerOptionsmodule:fabric-network.Gateway~DefaultQueryHandlerOptions <optional>
Options for the inbuilt default query handler capability. discoverymodule:fabric-network.Gateway~DiscoveryOptions <optional>
Discovery options. eventHubSelectionOptionsmodule:fabric-network.Gateway~DefaultEventHubSelectionOptions <optional>
Event hub selection options. checkpointermodule:fabric-network.Network~CheckpointerFactory <optional>
Event hub selection options. -
QueryHandler
-
Type:
- Object
Properties:
Name Type Description evaluatefunction Async function that takes a Query and resolves with the result of the query evaluation. -
QueryHandlerFactory(network)
-
Parameters:
Name Type Description networkmodule:fabric-network.Network The network on which queries are being evaluated. Returns:
A query handler. -
TxEventHandler
-
Type:
- Object
Properties:
Name Type Description startListeningfunction Async function that resolves when the handler has started listening for transaction commit events. Called after the transaction proposal has been accepted and prior to submission of the transaction to the orderer. waitForEventsfunction Async function that resolves (or rejects) when suitable transaction commit events have been received. Called after submission of the transaction to the orderer. cancelListeningfunction Cancel listening. Called if submission of the transaction to the orderer fails. -
TxEventHandlerFactory(transaction [, options])
-
Parameters:
Name Type Argument Description transactionmodule:fabric-network.Transaction The transaction for which the handler should listen for commit events. optionsmodule:fabric-network.Gateway~DefaultEventHandlerOptions <optional>
Options for the event handler capability. Returns:
A transaction event handler.