W Chain Docs
W Chain Website
  • πŸš€Welcome to W Chain
    • πŸ“–Introduction and Overview
    • πŸ›°οΈKey Features That Make W Chain
  • Working with a Node
    • πŸ–₯️Node
      • πŸ› οΈNon-Validator Node Setup
      • πŸ“¦Validator Node Setup
    • βš™οΈW Chain Client APIs
      • πŸ”„JSON-RPC
      • πŸ”ŒgRPC
  • 🀝Consensus
    • πŸ›‘οΈProof of Stake
  • πŸ—οΈArchitecture
    • W Chain Layer
  • ⚑Advanced Features
    • πŸ”Explorer
    • ⛓️Bridge
    • 🧩DApps Integration
  • πŸ’‘Tutorial
    • πŸ“²Web3 Wallet Setup
    • πŸ“œSmart contract
  • Audit Reports
Powered by GitBook
On this page
Export as PDF
  1. Working with a Node
  2. W Chain Client APIs

gRPC

gRPC (Google Remote Procedure Call) is a high-performance, open-source RPC framework developed by Google. It allows for efficient communication between client and server applications through HTTP/2. Unlike JSON-RPC, which uses JSON as the data exchange format, gRPC uses Protocol Buffers (Protobuf) as its interface definition language (IDL), which is faster and more compact.

Purpose in W Chain: In W Chain, gRPC is used to manage and monitor nodes and network performance. gRPC allows for more efficient communication between node operators and the W Chain network, particularly for querying node health, peer information, and transaction pool status.

gRPC enables:

  • Real-time monitoring of the blockchain state.

  • Access to advanced node operator information.

  • High-throughput communication for large-scale applications.

gRPC provides a more robust and structured communication model for node operations, making it suitable for scenarios requiring performance and reliability.

Key Benefits of gRPC in W Chain:

  • High Performance: gRPC's use of HTTP/2 and Protocol Buffers enables fast and efficient data transmission, making it ideal for high-throughput applications.

  • Streaming Support: gRPC natively supports streaming, allowing real-time data transfer between the node and the client.

  • Strongly Typed: gRPC uses Protocol Buffers, which ensure type safety and better error handling in data exchange.

Example Usage of gRPC in W Chain

Querying Peer Information

gRPC can be used by node operators to query details about connected peers, helping to monitor the health and performance of the node.

Command:

./wadzchain-testnet peers list

Explanation: This command retrieves a list of all connected peers, allowing node operators to see which other nodes their node is connected to. This is useful for troubleshooting networking issues and ensuring proper peer-to-peer communication.

Returned Value:

json
[
  "/ip4/51.20.119.238/tcp/1478/p2p/16Uiu2HAkvdoN3dkjd5P7monQsVLNPjAxKxiTVM9wvVnwMSHzbqGr",
  "/ip4/16.171.236.135/tcp/1478/p2p/16Uiu2HAmN5XaGZuioTa8FiCa6zSUcTQZR2nzhWnEdavQuGjkE3cu"]

Querying Node Transaction Pool

gRPC is also used to query the current state of the node’s transaction pool. The transaction pool contains pending transactions that have not yet been included in a block.

Command:

./wadzchain-testnet txpool status

Explanation: This command allows the node operator to view the number of pending transactions in the pool. If there are many pending transactions, it could indicate network congestion, and the operator might adjust node settings or gas fees to optimize performance.

Returned Value:

json
{
   "pending": 10,
   "queued": 5
}

Streaming Transaction Data

One of the most powerful features of gRPC is the ability to stream transaction data in real-time. This can be used by node operators to monitor network performance continuously, without the need to send individual queries for each new transaction.

PreviousJSON-RPCNextProof of Stake

Last updated 4 months ago

βš™οΈ
πŸ”Œ