QuDAG Protocol
Protocol implementation and coordination layer for the QuDAG system.
Features
- Component Orchestration: Coordinates crypto, DAG, and network layers
- Node Management: Complete node lifecycle management
- Message Handling: Protocol message processing and routing
- State Management: Persistent state storage and synchronization
- RPC Server: JSON-RPC API for external communication
- Configuration Management: Centralized configuration system
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
Examples
Basic Node Setup
use ;
async
Message Processing
use ;
// Create a protocol message
let message = Message ;
// Process the message
// protocol.process_message(message).await?;
RPC Server
use ;
async
State Persistence
use ;
// In-memory storage for testing
let memory_store = new;
// File-based storage for production
let file_store = new?;
// Store and retrieve state
memory_store.save_state.await?;
let retrieved = memory_store.load_state.await?;
Architecture
Protocol Stack
┌─────────────────────┐
│ RPC Server │ ← External API
├─────────────────────┤
│ Protocol Layer │ ← Message coordination
├─────────────────────┤
│ DAG Consensus │ ← Consensus algorithm
├─────────────────────┤
│ P2P Network │ ← Peer communication
├─────────────────────┤
│ Cryptography │ ← Quantum-resistant crypto
└─────────────────────┘
Core Components
- Node: Main coordinator for all subsystems
- Message Factory: Creates and validates protocol messages
- State Machine: Manages node state transitions
- RPC Server: Provides JSON-RPC API
- Persistence: State storage and recovery
- Configuration: System configuration management
Node Configuration
use ;
let config = NodeConfig ;
Message Types
The protocol supports various message types:
use ;
// Transaction messages
let tx_message = new;
// Consensus messages
let consensus_message = new;
// Network discovery
let discovery_message = new;
// Administrative commands
let admin_message = new;
RPC API
The protocol provides a JSON-RPC API:
Available Methods
node.status- Get node status and healthnode.peers- List connected peersnetwork.send_message- Send message to peerdag.get_tips- Get current DAG tipsdag.add_vertex- Add vertex to DAG
Example RPC Call
State Management
use ;
let state_machine = new;
// Transition states
state_machine.transition_to.await?;
state_machine.transition_to.await?;
// Get current state
let current = state_machine.current_state.await;
Error Handling
Comprehensive error types for protocol operations:
use ;
match result
Features
rocksdb: Enable RocksDB backend for state storagecompression: Enable message compressionmetrics: Enable performance metrics collection
Memory Management
The protocol includes memory tracking and optimization:
use ;
// Get current memory usage
let usage = get_memory_usage;
println!;
// Track memory for specific operations
let tracker = new;
// ... perform operations ...
let delta = tracker.delta;
Documentation
License
Licensed under either MIT or Apache-2.0 at your option.