The SDK needs a lot of information in order to allow applications to connect to the relevant network nodes.
- The CA and TLS certificates of the orderers and peers on the channel.
- IP addresses and port numbers of the orderers and peers.
- Relevant endorsement policies as well as which peers have the chaincode installed (so the application knows which peers to send chaincode proposals to)
How service discovery works in Fabric?
The application is bootstrapped knowing about a group of peers which are trusted by the application developer/administrator to provide authentic responses to discovery queries.
Note that in order for peers to be known to the discovery service, they must have an
To define these endpoints, you need to specify them in the
core.yaml of the peer.
The application issues a configuration query to the discovery service and obtains all the static information.
It also fetches information, such as any relevant endorsement policies, from the peer’s state database.
With service discovery, applications no longer need to specify which peers they need endorsements from. The SDK can simply send a query to the discovery service asking which peers are needed given a channel and a chaincode ID.
Capabilities of the discovery service
The discovery service can respond to the following queries:
- Configuration query: Returns the
MSPConfigof all organizations in the channel along with the orderer endpoints of the channel.
- Peer membership query: Returns the peers that have joined the channel.
- Endorsement query: Returns an endorsement descriptor for given chaincode(s) in a channel.
- Local peer membership query: Returns the local membership information of the peer that responds to the query. By default the client needs to be an administrator for the peer to respond to this query.