I am using the Node SDK with Hyperledger 1.0 and want to check if a channel with a specific name exists. Is there a way to query all existing channels? And is there a way to get a channel by name?
You cannot see all available channels, while you can leverage CSCC (Configuration System Chaincode) GetChannels API to get a list of channels client eligible to. You just need to invoke chaincode named CSCC.
The CSCC is the system chaincode, meaning it inherently built in into peer binary and loaded and "instantiate" during peer startup. You can find details here. Considering NodeJS the request will look as following
const request = {
chaincodeId : "cscc",
txId: 213213123123, // Some random transaction id
fcn: "GetChannels",
args: ['']
}
BTW you also can do it with peer cli:
peer channel list
来源:https://stackoverflow.com/questions/46449327/how-to-get-all-existing-channels-in-hyperledger-1-0-node-sdk