当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Channel.getChannelEventHubsForOrg方法代码示例

本文整理汇总了TypeScript中fabric-client.Channel.getChannelEventHubsForOrg方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Channel.getChannelEventHubsForOrg方法的具体用法?TypeScript Channel.getChannelEventHubsForOrg怎么用?TypeScript Channel.getChannelEventHubsForOrg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fabric-client.Channel的用法示例。


在下文中一共展示了Channel.getChannelEventHubsForOrg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Promise

			return new Promise((resolve, reject) => {
				// Get the list of channel event hubs for the current organization.
				// These will be peers with the "eventSource" role setting of true
				// and not the peers that have an "eventURL" defined. Peers with the
				// eventURL defined are peers with the legacy Event Hub that is on
				// a different port than the peer services. The peers with the
				// "eventSource" tag are running the channel-based event service
				// on the same port as the other peer services.
				let channel_event_hubs: ChannelEventHub[] = channel.getChannelEventHubsForOrg();
				// we should have the an channel event hub defined on the "peer0.org1.example.com"
				t.equals(channel_event_hubs.length, 2, 'Checking that the channel event hubs has two');

				let channel_event_hub = channel_event_hubs[0];
				t.equals(channel_event_hub.getPeerAddr(), 'localhost:7051', ' channel event hub address ');

				let handle = setTimeout(() => {
					t.fail('Timeout - Failed to receive replay the event for event1');
					channel_event_hub.unregisterTxEvent(query_tx_id);
					channel_event_hub.disconnect(); //shutdown down since we are done
				}, 10000);

				channel_event_hub.registerTxEvent(query_tx_id, (txnid, code, block_num) => {
					clearTimeout(handle);
					t.pass('Event has been replayed with transaction code:' + code + ' for transaction id:' + txnid + ' for block_num:' + block_num);
					resolve('Got the replayed transaction');
				}, (error) => {
					clearTimeout(handle);
					t.fail('Failed to receive event replay for Event for transaction id ::' + query_tx_id);
					throw (error);
				},
					// a real application would have remembered the last block number
					// received and used that value to start the replay
					// Setting the disconnect to true as we do not want to use this
					// ChannelEventHub after the event we are looking for comes in
					{ startBlock: 0, disconnect: true }
				);
				t.pass('Successfully registered transaction replay for ' + query_tx_id);

				channel_event_hub.connect(); //connect to receive filtered blocks
				t.pass('Successfully called connect on the transaction replay event hub for filtered blocks');
			});
开发者ID:asararatnakar,项目名称:fabric-sdk-node-v11-v12-compatibility,代码行数:41,代码来源:test.ts


注:本文中的fabric-client.Channel.getChannelEventHubsForOrg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。