From b0052eae056735d440172ff282046a5c1f5c6ea2 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 13 Feb 2015 14:55:48 -0500 Subject: [PATCH] doesn't create same local destination twice --- ClientContext.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 2764722e..220aea6b 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -185,10 +185,20 @@ namespace client LogPrint ("New private keys file ", fullPath, " for ", m_AddressBook.ToAddress(keys.GetPublic ().GetIdentHash ()), " created"); } - auto localDestination = new ClientDestination (keys, isPublic); + ClientDestination * localDestination = nullptr; std::unique_lock l(m_DestinationsMutex); - m_Destinations[localDestination->GetIdentHash ()] = localDestination; - localDestination->Start (); + auto it = m_Destinations.find (keys.GetPublic ().GetIdentHash ()); + if (it != m_Destinations.end ()) + { + LogPrint (eLogWarning, "Local destination ", m_AddressBook.ToAddress(keys.GetPublic ().GetIdentHash ()), " alreday exists"); + localDestination = it->second; + } + else + { + localDestination = new ClientDestination (keys, isPublic); + m_Destinations[localDestination->GetIdentHash ()] = localDestination; + localDestination->Start (); + } return localDestination; }