Moving addition to peerstore after everyting is done

This commit is contained in:
jmjatlanta 2017-08-03 14:43:19 -05:00
parent 7155f604c1
commit c639359a4a

View file

@ -906,11 +906,6 @@ int libp2p_secio_handshake(struct SessionContext* local_session, struct RsaPriva
} }
remote_peer->connection_type = CONNECTION_TYPE_CONNECTED; remote_peer->connection_type = CONNECTION_TYPE_CONNECTED;
if (new_peer) {
libp2p_logger_debug("secio", "New connection. Adding Peer to Peerstore.\n");
libp2p_peerstore_add_peer(peerstore, remote_peer);
}
// negotiate encryption parameters NOTE: SelectBest must match, otherwise this won't work // negotiate encryption parameters NOTE: SelectBest must match, otherwise this won't work
// first determine order // first determine order
order = libp2p_secio_determine_order(propose_in, propose_out); order = libp2p_secio_determine_order(propose_in, propose_out);
@ -1078,6 +1073,11 @@ int libp2p_secio_handshake(struct SessionContext* local_session, struct RsaPriva
// set secure as default // set secure as default
local_session->default_stream = local_session->secure_stream; local_session->default_stream = local_session->secure_stream;
if (new_peer) {
libp2p_logger_debug("secio", "New connection. Adding Peer to Peerstore.\n");
libp2p_peerstore_add_peer(peerstore, remote_peer);
}
retVal = 1; retVal = 1;
libp2p_logger_log("secio", LOGLEVEL_DEBUG, "Handshake complete\n"); libp2p_logger_log("secio", LOGLEVEL_DEBUG, "Handshake complete\n");