• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fabric-client.Channel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Promise

			return new Promise((resolve, reject) => {
				// get a new ChannelEventHub when registering a listener
				// with startBlock or endBlock when doing a replay
				// The ChannelEventHub must not have been connected or have other
				// listeners.
				let channel_event_hub: ChannelEventHub = channel.newChannelEventHub('peer0.org1.example.com');

				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,代码行数:33,代码来源:test.ts


示例2:

		}).then(() => {
			t.pass('Successfully waited to make sure new channel was created.');
			channel = client.getChannel(channel_name);

			let txId = client.newTransactionID(true);
			let request: OrdererRequest = { txId };
			return channel.getGenesisBlock(request);
		}).then((block: Block) => {
开发者ID:asararatnakar,项目名称:fabric-sdk-node-v11-v12-compatibility,代码行数:8,代码来源:test.ts


示例3: Error

		}).then((results: ProposalResponseObject) => {
			var proposalResponses = results[0];
			var proposal = results[1];
			if (proposalResponses && proposalResponses[0].response && proposalResponses[0].response.status === 200) {
				t.pass('Successfully sent Proposal and received ProposalResponse');
				var request: TransactionRequest = {
					proposalResponses: proposalResponses,
					proposal: proposal,
					txId: instansiate_tx_id //required to indicate that this is an admin transaction
					//orderer : not specifying, the first orderer defined in the
					//          connection profile for this channel will be used
				};

				return channel.sendTransaction(request); // still have org2 admin as signer
			} else {
				t.fail('Failed to send  Proposal or receive valid response. Response null or status is not 200. exiting...');
				throw new Error('Failed to send Proposal or receive valid response. Response null or status is not 200. exiting...');
			}
		}).then((response: BroadcastResponse) => {
开发者ID:asararatnakar,项目名称:fabric-sdk-node-v11-v12-compatibility,代码行数:19,代码来源:test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript factories.createRoutine函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fable-utils.client类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap