newNode method
Creates a new libp2p Host from the Config.
This function consumes the config. Do not reuse it.
Implementation
Future<Host> newNode() async {
// Validate configuration
_validate();
// This is a placeholder implementation that outlines the steps involved in creating a Host.
// In a real implementation, these steps would be implemented with actual code.
// 1. Create a PeerId from the private key
final peerId = await _createPeerId();
// 2. Create a Network with the transports and security protocols
final network = await _createNetwork(peerId); // Creates Swarm
// 3. Create a Host with the Network
final host = await _createHost(network, peerId); // Creates BasicHost, Swarm gets host set.
// 4. Network listening will be initiated by host.start() if listenAddrs are configured.
// Removing direct network.listen() call here to avoid double listening.
_logger.info('[Config.newNode] for peer ${peerId.toString()}: Host created. Listening will be handled by host.start().');
return host;
}