start method
Starts the web node.
Implementation
Future<void> start() async {
if (_started) return;
// Generate/Load ID via router (router usually generates one if generic)
await _router.initialize();
// Initialize components that depend on Router/PeerID
_bitswap = BitswapHandler(_config, _blockStore, _router);
_pubsub = PubSubClient(_router, _router.peerID);
// Security & IPNS
_securityManager = SecurityManagerWeb(
_config.security,
MetricsCollector(_config),
);
final delegateUrl =
_config.network.delegatedRoutingEndpoint ?? 'https://delegated-ipfs.io';
IDHTHandler dht = DelegateDHTHandler(delegateUrl);
_ipns = IPNSHandler(_config, _securityManager, dht, _pubsub);
await _router.start();
await _bitswap.start();
await _pubsub.start();
await _ipns.start();
// Connect to bootstrap peers
for (final peer in bootstrapPeers) {
try {
await _router.connect(peer);
} catch (e) {
// Log error but continue
// print('Failed to connect to bootstrap peer $peer: $e');
}
}
_started = true;
}