简体   繁体   中英

Why does connection profile in Hyperledger Fabric has gRPC URL?

In the client applications (using Node/Go) we provide connection profile to identify the endpoints of endorsers.

There we specify endpoint of peer in terms of grpc://localhost:port but actually gRPC runs on HTTP2 right?

Then does the Fabric SDK convert the endpoint to a HTTP url or is it handled by fabric peer code?

I mean how is grpc endpoint converted to an HTTP one?

Or does the peer expose a grpc endpoint itself? If yes, how?

For communicating between the front-end and the Hyperledger Fabric Layer, we have two ways, one to use the gRPC calls OR use one of the SDKs provided by the Hyperledger Community. There are no REST API calls after v1.0, as opposed to v0.6, which had REST API calls, where you could use the IP Addresses to fire transactions to the Orderer, then Consensus.

Making it limited to gRPC and SDKs improves the design and connection security issues, which is vital for the Blockchain to work. gRPC is the HTTPS 2.0 protocol for communication which is faster and has improved security features over HTTPS 1.1. SDKs use gRPC calls to communicate to the network. So, putting it plainly, if you need to communicate with the Network, you need to use gRPC calls only

As suggested by @david_k in comments above, the URL in connection profile is used for extracting the host and port number after identifying whether it is grpc or grpcs (over SSL) call.

To verify:

  1. Deploy the fabcar sample and install the node modules.
  2. Go to the Endpoint.js file in the fabric-common node module inside the lib directory. Edit the line corresponding to line 44 here .
  3. Go to the first-network directory (the network used by fabcar sample) to edit the connection profile. Replace the grpcs in the peer and orderer URL corresponding to the edit you made to the Endpoint.js file in node modules.
  4. Return back to the javascript directory and fetch the wallet identities.
  5. Modify the invoke.js to read the new connection profile.
  6. Execute it to see that the transaction is submitted successfully.

Therefore, we can identify that only the host and port are fetched from the URL to be used for making a grpc/grpcs call to the fabric network.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM