I'm currently learning how blockchain works, just out of personal curiosity. I'm going through this course and now I've setup the peer-to-peer connectivity using web sockets. Multiple instances of the blockchain application can now run and communicate with each other using these sockets.
The one downside of the course implementation is how the instances know how to find each other. Essentially they need to be explicitly configured to communicate. In my current project, I have it setup with 3 instances. One opens a socket on port 5001 and connects to nothing else. The other opens a socket on port 5002 and connects to the instance on 5001. And the third opens a socket on port 5003 and connects to the instances on 5002 and 5001.
The point is, all three are explicitly configured like that. All three must be started in exactly that order so they can properly connect to the others. While this is fine for a practice implementation, I know that's not how a real blockchain implementation must be working out there in the wild. There must be some mechanism of discovery that takes place which would allow any of these instances to locate whichever others are currently running.
Networking is not my area of expertise, so I'm at a loss on how this could be done.