How can i get the list of all channels in an Hyperledger Fabric network?
If not possible, can i list all the channels that a particular organization has joined.
I know i can use the queryChannels API of Client class to get the list of channel a particular peer has joined but i want to know about the channel name of all the peers in particular organization at least.
Asked
Active
Viewed 1,203 times
0

Sourav
- 145
- 1
- 14
1 Answers
0
You can use getChannelPeers method after you got the channel list with queryChannels
let result = await client.queryChannels(peer);
result.channels.forEach(channel => {
let channelName = channel.channel_id;
let channelInstance = client.getChannel(channelName);
let channelPeers = channel.getChannelPeers();
});

Hnampk
- 517
- 6
- 17
-
I think my question is not clear. Suppose there is an organization Org1 has three peer (P1, P2, and P3) and there are four channel C1, C2, C3 and C4 in a network. P1 has joined channel C1, P2 has joined C2 and P3 has joined C3. Now i want to write an API such that i can get all channel name joined by peers of org1 (Here, answer is C1, C2 and C3) – Sourav Apr 25 '19 at 11:08
-
1hi @Sourav, I think you could reach your target by following these steps: (1) Get the list of Peer by using `client.getPeersForOrg(mspid)` method. (2) After you get the peer list, you can call `client.queryChannels(peer)` method for each peer in that list Hope this can help you! – Hnampk Apr 26 '19 at 01:29