pub trait TerminalRpc {
// Required method
fn get_overview(&self, refresh: Option<u32>) -> Result<Overview>;
}Expand description
RPC Terminal Module, specifically designed for TUI (Terminal User Interface) applications.
This module provides optimized endpoints for terminal-based monitoring tools and dashboards, with intelligent caching to minimize performance impact while providing real-time insights.
§Intended Use Cases
- TUI Monitoring Dashboards: Real-time node status displays in terminal environments
- System Administration: Command-line tools for node health monitoring
- Resource Monitoring: Tracking system resource usage over time
- Network Diagnostics: Monitoring peer connectivity and performance
§Performance Considerations
The module uses a multi-tiered caching strategy with TTLs optimized for different data change frequencies. For frequent monitoring calls, use cached data (refresh: null) to minimize system load. Force refresh only when real-time accuracy is critical.
§Refresh Flags Guide
Use RefreshKind bit flags strategically:
- Monitoring Mode: Use
nullor0for cached data (recommended) - Diagnostics Mode: Use specific flags to refresh relevant data only
- Full Sync: Use
EVERYTHING(31) for complete data refresh
Required Methods§
Sourcefn get_overview(&self, refresh: Option<u32>) -> Result<Overview>
fn get_overview(&self, refresh: Option<u32>) -> Result<Overview>
Returns a comprehensive overview of CKB node status for TUI applications.
This method aggregates system metrics, mining information, transaction pool status, cells statistics, and network peer information into a single response, optimized for terminal-based monitoring interfaces.
§Params
refresh- Optional bit flags to force refresh specific cached data types. UseRefreshKindbit flags to control which data to refresh:0x1(SYSTEM_INFO): Force refresh system information (CPU, memory, disk, network)0x2(MINING_INFO): Force refresh mining information (difficulty, hash rate)0x4(TX_POOL_INFO): Force refresh transaction pool information0x8(CELLS_INFO): Force refresh cells information0x10(NETWORK_INFO): Force refresh network peer latency information0x1F(EVERYTHING): Force refresh all cached datanullor0: Use cached data when available (recommended for frequent calls)
§Returns
Returns an Overview structure containing:
- System information (CPU, memory, disk, network metrics)
- Mining information (network difficulty and hash rate)
- Transaction pool statistics
- Blockchain cells information
- Network peer connectivity and latency data
- CKB node version
§Cache Behavior
Data is cached with different TTL values to balance freshness with performance:
- System info: 5 seconds (changes frequently)
- Mining info: 10 seconds (moderate change frequency)
- Transaction pool: 2 seconds (highly dynamic)
- Cells info: 30 seconds (relatively static)
- Network info: 10 seconds (moderate change frequency)
§Examples
Get overview using cached data:
Request
{
"jsonrpc": "2.0",
"method": "get_overview",
"params": [null],
"id": 1
}Response
{
"jsonrpc": "2.0",
"result": {
"sys": {
"cpu_usage": 25.5,
"memory": 134217728,
"virtual_memory": 268435456,
"disk_usage": {
"read_bytes": 1048576,
"total_read_bytes": 1073741824,
"written_bytes": 524288,
"total_written_bytes": 536870912
},
"global": {
"total_memory": 8589934592,
"used_memory": 4294967296,
"global_cpu_usage": 150.0,
"disks": [
{
"total_space": 1000000000000,
"available_space": 500000000000,
"is_removable": false
}
],
"networks": [
{
"interface_name": "eth0",
"received": 1048576,
"total_received": 1073741824,
"transmitted": 524288,
"total_transmitted": 536870912
}
]
}
},
"mining": {
"difficulty": "0x1e083126",
"hash_rate": "0x174876e800"
},
"pool": {
"pending": "0x64",
"proposed": "0x32",
"orphan": "0x5",
"committing": "0x1f",
"total_recent_reject_num": "0x3",
"total_tx_size": "0x100000",
"total_tx_cycles": "0x2dc6c",
"last_txs_updated_at": "0x187b3d137a1",
"max_tx_pool_size": "0x20000000"
},
"cells": {
"total_occupied_capacities": "0x15f1e59b76c000",
"estimate_live_cells_num": "0x989680"
},
"network": {
"connected_peers": "0x33",
"outbound_peers": "0x1f",
"inbound_peers": "0x14",
"peers": [
{
"peer_id": 0,
"is_outbound": true,
"latency_ms": "0x98",
"address": "/ip4/18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN"
},
{
"peer_id": 1,
"is_outbound": false,
"latency_ms": "0xa5",
"address": "/ip4/18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN"
},
{
"peer_id": 2,
"is_outbound": true,
"latency_ms": "0x0",
"address": "/ip4/18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN"
},
{
"peer_id": 3,
"is_outbound": true,
"latency_ms": "0x8c",
"address": "/ip4/18.185.102.19/tcp/8115/p2p/QmXwUgF48ULy6hkgfqrEwEfuHW7WyWyWauueRDAYQHNDfN"
}
]
},
"version": "0.100.0 (abc123def 2023-12-01)"
},
"id": 1
}