RPC Handler Architecture
Understanding the Foundation of Rippled's RPC System
Introduction
Core Architecture Components
1. Central Handler Table
// Handler table structure (simplified)
std::map<std::string, HandlerInfo> handlerTable = {
{"account_info", {&doAccountInfo, Role::USER, RPC::NEEDS_CURRENT_LEDGER}},
{"ledger", {&doLedger, Role::USER, RPC::NEEDS_NETWORK_CONNECTION}},
{"submit", {&doSubmit, Role::USER, RPC::NEEDS_CURRENT_LEDGER}},
// ... hundreds of other handlers
};2. Handler Information Structure
3. Handler Function Signature
4. JsonContext Object
Handler Registration Process
Step 1: Define the Handler Function
Step 2: Add to Handler Table
Step 3: Declare in Header (Optional)
Handler Discovery and Dispatch
1. Request Reception
2. Command Lookup
3. Permission Check
4. Condition Validation
5. Handler Invocation
6. Response Serialization
Handler Capability Flags
Flag
Meaning
Example Use Case
Multi-Transport Support
HTTP (JSON-RPC)
WebSocket (JSON-RPC)
gRPC (Protocol Buffers)
Versioning and Compatibility
Real-World Example: AccountInfo Handler
Conclusion
Last updated

