feat: implement automatic ring positioning

- Remove manual --position parameter from CLI
- Add automatic optimal position calculation based on gap analysis
- Implement dynamic ring topology management
- Add position tracking and synchronization across nodes
- Add topology command for visual ring structure inspection
- Clean up unused variables and dead code
- Simplify node setup with automatic positioning
Este commit está contenido en:
ale
2025-06-17 00:15:09 +02:00
padre e238b4b307
commit 303b3fa9f7
Se han modificado 7 ficheros con 299 adiciones y 87 borrados

Ver fichero

@@ -77,12 +77,13 @@ npm run start:node -- --port 8083 --bootstrap localhost:8080
--port <port> # Port to listen on (default: random)
--id <id> # Node ID (default: auto-generated UUID)
--bootstrap <addr> # Bootstrap node address (host:port)
--position <pos> # Initial ring position (default: 0)
--ice-servers <json> # ICE servers configuration (JSON array)
--config <file> # Load configuration from JSON file
--help # Show help message
```
**Note**: Ring positions are now assigned automatically for optimal network topology. The system calculates the best position for each node to ensure even distribution around the ring.
### WebRTC ICE Servers Configuration
The Ring Network uses WebRTC for peer-to-peer connections. You can configure custom ICE servers (STUN/TURN) for better connectivity:
@@ -137,6 +138,7 @@ Once a node is running, you can use these commands:
- `info` - Show network information
- `peers` - List connected peers
- `connections` - Show persistent connection status
- `topology` - Show ring topology and node positions
- `help` - Show available commands
- `quit` - Exit the node
@@ -148,6 +150,7 @@ Once a node is running, you can use these commands:
- `get <key>` - Retrieve data from storage
- `propose <text>` - Create a consensus proposal
- `vote <id> <yes|no>` - Vote on a proposal
- `topology` - Show ring topology and node positions
## 🔮 Oracle Services
@@ -183,6 +186,31 @@ Oracle nodes provide enhanced services to the network:
- Usage analytics
- Historical data tracking
## 🎯 Automatic Ring Positioning
The Ring Network now features **automatic node positioning** that optimizes network topology without manual configuration:
### Key Features
- **Optimal Placement**: New nodes are automatically positioned in the largest gap between existing nodes
- **Even Distribution**: Nodes are distributed evenly around the virtual ring for balanced load
- **Dynamic Rebalancing**: Network topology adjusts automatically when nodes join or leave
- **No Manual Configuration**: Eliminates the need to manually specify ring positions
### How It Works
1. **Virtual Ring**: The network uses a virtual ring of 1000 positions
2. **Gap Analysis**: When a new node joins, the system finds the largest gap between existing nodes
3. **Optimal Insertion**: The new node is placed in the middle of the largest gap
4. **Topology Update**: All nodes update their neighbor connections based on the new topology
5. **Automatic Rebalancing**: The system can redistribute nodes evenly when needed
### Benefits
- **Simplified Setup**: No need to calculate or specify positions manually
- **Better Performance**: Optimal positioning improves routing efficiency
- **Self-Healing**: Network automatically adapts to node changes
- **Scalability**: Easy to add new nodes without topology planning
Use the `topology` command in any node to view the current ring structure and positions.
## 🧪 Testing
Run the test suite to verify network functionality: