74
index.js
Archivo normal
74
index.js
Archivo normal
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import chalk from 'chalk';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length === 0 || args.includes('--help')) {
|
||||
console.log(`
|
||||
${chalk.blue.bold('🔗 Ring Network - Two Ring Topology with WebRTC')}
|
||||
|
||||
A decentralized network implementation using WebRTC for peer-to-peer communication
|
||||
in a double ring topology with optional Oracle nodes.
|
||||
|
||||
${chalk.green('Usage:')}
|
||||
npm start - Show this help
|
||||
npm run start:node [opts] - Start a regular network node
|
||||
npm run start:oracle [opts] - Start an Oracle node
|
||||
node node.js [opts] - Start a regular network node directly
|
||||
node oracle.js [opts] - Start an Oracle node directly
|
||||
|
||||
${chalk.yellow('Options:')}
|
||||
--port <port> Port to listen on (default: random)
|
||||
--id <id> Node ID (default: auto-generated)
|
||||
--bootstrap <addr> Bootstrap node address (host:port)
|
||||
--position <pos> Initial ring position (default: 0)
|
||||
|
||||
${chalk.cyan('Examples:')}
|
||||
# Start first node (bootstrap)
|
||||
npm run start:oracle -- --port 8080
|
||||
|
||||
# Start second node connecting to first
|
||||
npm run start:node -- --port 8081 --bootstrap localhost:8080
|
||||
|
||||
# Start third node (oracle) connecting to network
|
||||
npm run start:oracle -- --port 8082 --bootstrap localhost:8080
|
||||
|
||||
${chalk.magenta('Network Features:')}
|
||||
✅ Double ring topology (inner and outer rings)
|
||||
✅ WebRTC peer-to-peer connections
|
||||
✅ Automatic peer discovery and connection
|
||||
✅ Message routing through rings
|
||||
✅ Oracle nodes with enhanced capabilities
|
||||
✅ Distributed data storage (Oracle)
|
||||
✅ Consensus mechanisms (Oracle)
|
||||
✅ Network health monitoring (Oracle)
|
||||
✅ Advanced routing strategies (Oracle)
|
||||
|
||||
${chalk.blue('Oracle Services:')}
|
||||
🔮 network-analysis - Analyze network topology and health
|
||||
🔮 data-storage - Distributed data storage with replication
|
||||
🔮 consensus - Consensus mechanisms for decisions
|
||||
🔮 routing - Advanced routing strategies
|
||||
🔮 health-check - Network health monitoring
|
||||
🔮 network-metrics - Collect and provide metrics
|
||||
|
||||
${chalk.red('Quick Start:')}
|
||||
1. Install dependencies: npm install
|
||||
2. Start first Oracle: npm run start:oracle -- --port 8080
|
||||
3. Start regular node: npm run start:node -- --port 8081 --bootstrap localhost:8080
|
||||
4. Start more nodes by repeating step 3 with different ports
|
||||
|
||||
For more information, see the README.md file.
|
||||
`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// If specific arguments are passed, delegate to appropriate script
|
||||
if (args.includes('--oracle')) {
|
||||
console.log(chalk.yellow('🔮 Starting Oracle Node...'));
|
||||
import('./oracle.js');
|
||||
} else {
|
||||
console.log(chalk.blue('🔗 Starting Regular Node...'));
|
||||
import('./node.js');
|
||||
}
|
||||
Referencia en una nueva incidencia
Block a user