From c639359a4ac3fa1a1205a5761479a7bea9e822af Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Thu, 3 Aug 2017 14:43:19 -0500 Subject: [PATCH] Moving addition to peerstore after everyting is done --- secio/secio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/secio/secio.c b/secio/secio.c index 9a6d590..60c4911 100644 --- a/secio/secio.c +++ b/secio/secio.c @@ -906,11 +906,6 @@ int libp2p_secio_handshake(struct SessionContext* local_session, struct RsaPriva } 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 // first determine order 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 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; libp2p_logger_log("secio", LOGLEVEL_DEBUG, "Handshake complete\n");