|
143 | 143 | * @returns {Promise<void>}
|
144 | 144 | */
|
145 | 145 |
|
| 146 | +/** |
| 147 | + * Factory function to obtain transaction event handler instances. Called on every transaction submit. |
| 148 | + * @typedef {Function} TxEventHandlerFactory |
| 149 | + * @memberof module:fabric-network |
| 150 | + * @param {string} transactionId The ID of the transaction being submitted. |
| 151 | + * @param {module:fabric-network.Network} network The network on which this transaction is being submitted. |
| 152 | + * @returns {module:fabric-network.TxEventHandler} A transaction event handler. |
| 153 | + */ |
| 154 | + |
| 155 | +/** |
| 156 | + * Handler used to wait for commit events when a transaction is submitted. |
| 157 | + * @interface TxEventHandler |
| 158 | + * @memberof module:fabric-network |
| 159 | + */ |
| 160 | +/** |
| 161 | + * Resolves when the handler has started listening for transaction commit events. Called after the transaction proposal |
| 162 | + * has been accepted and prior to submission of the transaction to the orderer. |
| 163 | + * @function module:fabric-network.TxEventHandler#startListening |
| 164 | + * @async |
| 165 | + * @returns {Promise<void>} |
| 166 | + */ |
| 167 | +/** |
| 168 | + * Resolves (or rejects) when suitable transaction commit events have been received. Called after submission of the |
| 169 | + * transaction to the orderer. |
| 170 | + * @function module:fabric-network.TxEventHandler#waitForEvents |
| 171 | + * @async |
| 172 | + * @returns {Promise<void>} |
| 173 | + */ |
| 174 | +/** |
| 175 | + * Called if submission of the transaction to the orderer fails. |
| 176 | + * @function module:fabric-network.TxEventHandler#cancelListening |
| 177 | + * @returns {void} |
| 178 | + */ |
| 179 | + |
| 180 | +/** |
| 181 | + * Factory function to obtain query handler instances. Called on every network creation. |
| 182 | + * @typedef {Function} QueryHandlerFactory |
| 183 | + * @memberof module:fabric-network |
| 184 | + * @param {module:fabric-network.Network} network The network on which queries are being evaluated. |
| 185 | + * @returns {module:fabric-network.QueryHandler} A query handler. |
| 186 | + */ |
| 187 | + |
| 188 | +/** |
| 189 | + * Handler used to obtain query results from peers when a transaction is evaluated. |
| 190 | + * @interface QueryHandler |
| 191 | + * @memberof module:fabric-network |
| 192 | + */ |
| 193 | +/** |
| 194 | + * Called when a transaction is evaluated to obtain query results from suitable network peers. |
| 195 | + * @function module:fabric-network.QueryHandler#evaluate |
| 196 | + * @async |
| 197 | + * @param {module:fabric-network.Query} query Query object that can be used by the handler to send the query to |
| 198 | + * specific peers. |
| 199 | + * @returns {Promise<Buffer>} |
| 200 | + */ |
| 201 | + |
| 202 | +/** |
| 203 | + * Used by query handler implementations to evaluate transactions on peers of their choosing. |
| 204 | + * @interface Query |
| 205 | + * @memberof module:fabric-network |
| 206 | + */ |
| 207 | +/** |
| 208 | + * Get query results from specified peers. |
| 209 | + * @function module:fabric-network.Query#evaluate |
| 210 | + * @async |
| 211 | + * @param {Endorser[]} peers |
| 212 | + * @returns {Promise<Array<module:fabric-network.Query~QueryResponse | Error>>} |
| 213 | + */ |
| 214 | + |
| 215 | +/** |
| 216 | + * @typedef {Object} Query~QueryResponse |
| 217 | + * @memberof module:fabric-network |
| 218 | + * @property {boolean} isEndorsed True if the proposal was endorsed by the peer. |
| 219 | + * @property {number} status The status value from the endorsement. This attriibute will be set by the chaincode. |
| 220 | + * @property {Buffer} payload The payload value from the endorsement. This attribute may be considered the query value |
| 221 | + * if the proposal was endorsed by the peer. |
| 222 | + * @property {string} message The message value from the endorsement. This property contains the error message from |
| 223 | + * the peer if it did not endorse the proposal. |
| 224 | + */ |
| 225 | + |
| 226 | +/** |
| 227 | + * A callback function that will be invoked when either a peer communication error occurs or a transaction commit event |
| 228 | + * is received. Only one of the two arguments will have a value for any given invocation. |
| 229 | + * @callback Network~CommitListener |
| 230 | + * @memberof module:fabric-network |
| 231 | + * @param {module:fabric-network.Network~CommitError} [error] Peer communication error. |
| 232 | + * @param {module:fabric-network.Network~CommitEvent} [event] Transaction commit event from a specific peer. |
| 233 | + */ |
| 234 | + |
| 235 | +/** |
| 236 | + * @typedef {Error} Network~CommitError |
| 237 | + * @memberof module:fabric-network |
| 238 | + * @property {Endorser} peer The peer that raised this error. |
| 239 | + */ |
| 240 | + |
| 241 | +/** |
| 242 | + * @typedef {EventInfo} Network~CommitEvent |
| 243 | + * @memberof module:fabric-network |
| 244 | + * @property {Endorser} peer The peer that raised this error. |
| 245 | + */ |
| 246 | + |
| 247 | +/** |
| 248 | + * A callback function that will be invoked when a block event is received. Block events will be received in order and |
| 249 | + * without duplication. |
| 250 | + * @callback Network~CommitListener |
| 251 | + * @memberof module:fabric-network |
| 252 | + * @async |
| 253 | + * @param {module:fabric-network.Network~BlockEvent} event Block event. |
| 254 | + * @returns {Promise<void>} |
| 255 | + */ |
| 256 | + |
| 257 | +/** |
| 258 | + * @typedef {EventInfo} Network~BlockEvent |
| 259 | + * @memberof module:fabric-network |
| 260 | + */ |
| 261 | + |
| 262 | +/** |
| 263 | + * A Network represents the set of peers in a Fabric network. |
| 264 | + * Applications should get a Network instance using the |
| 265 | + * gateway's [getNetwork]{@link module:fabric-network.Gateway#getNetwork} method. |
| 266 | + * @interface Network |
| 267 | + * @memberof module:fabric-network |
| 268 | + */ |
| 269 | + |
| 270 | +/** |
| 271 | + * Get the owning Gateway connection. |
| 272 | + * @method Network#getGateway |
| 273 | + * @memberof module:fabric-network |
| 274 | + * @returns {module:fabric-network.Gateway} A Gateway. |
| 275 | + */ |
| 276 | + |
| 277 | +/** |
| 278 | + * Get an instance of a contract (chaincode) on the current network. |
| 279 | + * @method Network#getContract |
| 280 | + * @memberof module:fabric-network |
| 281 | + * @param {string} chaincodeId - the chaincode identifier. |
| 282 | + * @param {string} [name] - the name of the contract. |
| 283 | + * @param {string[]} [collections] - the names of collections defined for this chaincode. |
| 284 | + * @returns {module:fabric-network.Contract} the contract. |
| 285 | + */ |
| 286 | + |
| 287 | +/** |
| 288 | + * Get the underlying channel object representation of this network. |
| 289 | + * @method Network#getChannel |
| 290 | + * @memberof module:fabric-network |
| 291 | + * @returns {Channel} A channel. |
| 292 | + */ |
| 293 | + |
| 294 | +/** |
| 295 | + * Add a listener to receive transaction commit and peer disconnect events for a set of peers. |
| 296 | + * @method Network#addCommitListener |
| 297 | + * @memberof module:fabric-network |
| 298 | + * @param {module:fabric-network.Network~CommitListener} listener A transaction commit listener callback function. |
| 299 | + * @param {Endorser[]} peers The peers from which to receive events. |
| 300 | + * @param {string} transactionId A transaction ID. |
| 301 | + * @returns {module:fabric-network.Network~CommitListener} The added listener. |
| 302 | + * @example |
| 303 | + * const listener: CommitListener = (error, event) => { |
| 304 | + * if (error) { |
| 305 | + * // Handle peer communication error |
| 306 | + * } else { |
| 307 | + * // Handle transaction commit event |
| 308 | + * } |
| 309 | + * } |
| 310 | + * const peers = network.channel.getEndorsers(); |
| 311 | + * await network.addCommitListener(listener, peers, transactionId); |
| 312 | + */ |
| 313 | + |
| 314 | +/** |
| 315 | + * Remove a previously added transaction commit listener. |
| 316 | + * @method Network#removeCommitListener |
| 317 | + * @memberof module:fabric-network |
| 318 | + * @param {module:fabric-network.Network~CommitListener} listener A transaction commit listener callback function. |
| 319 | + */ |
| 320 | + |
| 321 | +/** |
| 322 | + * Add a listener to receive block events for this network. Blocks will be received in order and without duplication. |
| 323 | + * @method Network#addBlockListener |
| 324 | + * @memberof module:fabric-network |
| 325 | + * @param {module:fabric-network.Network~BlockListener} listener A block listener callback function. |
| 326 | + * @returns {module:fabric-network.Network~BlockListener} The added listener. |
| 327 | + * @example |
| 328 | + * const listener: BlockListener = async (event) => { |
| 329 | + * // Handle block event, then (optionally) remove myself as a listener |
| 330 | + * network.removeBlockListener(listener); |
| 331 | + * } |
| 332 | + * await network.addBlockListener(listener); |
| 333 | + */ |
| 334 | + |
| 335 | +/** |
| 336 | + * Remove a previously added block listener. |
| 337 | + * @method Network#removeBlockListener |
| 338 | + * @memberof module:fabric-network |
| 339 | + * @param listener {module:fabric-network.Network~BlockListener} A block listener callback function. |
| 340 | + */ |
| 341 | + |
| 342 | + |
146 | 343 | module.exports.Gateway = require('./lib/gateway');
|
147 | 344 | module.exports.Wallet = require('./lib/impl/wallet/wallet').Wallet;
|
148 | 345 | module.exports.Wallets = require('./lib/impl/wallet/wallets').Wallets;
|
149 | 346 | module.exports.IdentityProviderRegistry = require('./lib/impl/wallet/identityproviderregistry').IdentityProviderRegistry;
|
150 | 347 | module.exports.HsmX509Provider = require('./lib/impl/wallet/hsmx509identity').HsmX509Provider;
|
151 | 348 | module.exports.DefaultEventHandlerStrategies = require('./lib/impl/event/defaulteventhandlerstrategies');
|
152 |
| -module.exports.QueryHandlerStrategies = require('./lib/impl/query/queryhandlerstrategies'); |
| 349 | +module.exports.DefaultQueryHandlerStrategies = require('./lib/impl/query/defaultqueryhandlerstrategies'); |
153 | 350 | module.exports.TimeoutError = require('./lib/errors/timeouterror').TimeoutError;
|
0 commit comments