When Transport::ConnectToBootstrapEndpoint function was called, it started to wait on the on_connectionadded and on_connectionlost functors. The problem was, that these could have been called by any Connection owned by the tranport, not only the one we've just initiated inside the ConnectToBootstrapEndpoint function. What I've done is I added a OnConnect handler to Connection::Connect method so that the work we need to do will only happen as a response to events happening inside the particular Connection object.
When Transport::ConnectToBootstrapEndpoint function was called, it started to wait on the on_connectionadded and on_connectionlost functors. The problem was, that these could have been called by any Connection owned by the tranport, not only the one we've just initiated inside the ConnectToBootstrapEndpoint function. What I've done is I added a OnConnect handler to Connection::Connect method so that the work we need to do will only happen as a response to events happening inside the particular Connection object.