本文整理汇总了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;未经允许,请勿转载。 |
请发表评论