Protocol Buffers
Protocal Buffer
https://developers.google.com/protocol-buffers
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.

gRPC
By default gRPC uses Google’s mature open source mechanism for serializing structured data (although it can be used with other data formats such as JSON).
Node.js API Reference
https://grpc.io/grpc/node/index.html
範例:
https://github.com/EasonWang01/gRPC-Example
getInfo.proto
server.js
client.js
實驗步驟:
1.node server
2.node client
3.彈出提示訊息後輸入,getAccountBalance或是getLastestBlock
注意
.proto文件內如果有RPC的參數不需要則不可以不寫,還是要寫一個空的message然後填入括號
server 有新的RPC function記得要在server.addService 寫上
client呼叫的function如果不需要參數則還是要在第一個參數寫上空的{}
Last updated
Was this helpful?