mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
use std::map for unconfirmed tags
This commit is contained in:
24
Garlic.cpp
24
Garlic.cpp
@@ -94,26 +94,16 @@ namespace garlic
|
|||||||
void GarlicRoutingSession::TagsConfirmed (uint32_t msgID)
|
void GarlicRoutingSession::TagsConfirmed (uint32_t msgID)
|
||||||
{
|
{
|
||||||
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
auto it = m_UnconfirmedTagsMsgs.find (msgID);
|
||||||
{
|
if (it != m_UnconfirmedTagsMsgs.end ())
|
||||||
auto& tags = *it;
|
|
||||||
if (tags->msgID == msgID)
|
|
||||||
{
|
{
|
||||||
|
auto& tags = it->second;
|
||||||
if (ts < tags->tagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
if (ts < tags->tagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tags->numTags; i++)
|
for (int i = 0; i < tags->numTags; i++)
|
||||||
m_SessionTags.push_back (tags->sessionTags[i]);
|
m_SessionTags.push_back (tags->sessionTags[i]);
|
||||||
}
|
}
|
||||||
it = m_UnconfirmedTagsMsgs.erase (it);
|
m_UnconfirmedTagsMsgs.erase (it);
|
||||||
}
|
|
||||||
else if (ts >= tags->tagsCreationTime + OUTGOING_TAGS_CONFIRMATION_TIMEOUT)
|
|
||||||
{
|
|
||||||
if (m_Owner)
|
|
||||||
m_Owner->RemoveDeliveryStatusSession (tags->msgID);
|
|
||||||
it = m_UnconfirmedTagsMsgs.erase (it);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,10 +134,10 @@ namespace garlic
|
|||||||
// delete expired unconfirmed tags
|
// delete expired unconfirmed tags
|
||||||
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
||||||
{
|
{
|
||||||
if (ts >= (*it)->tagsCreationTime + OUTGOING_TAGS_CONFIRMATION_TIMEOUT)
|
if (ts >= it->second->tagsCreationTime + OUTGOING_TAGS_CONFIRMATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
if (m_Owner)
|
if (m_Owner)
|
||||||
m_Owner->RemoveDeliveryStatusSession ((*it)->msgID);
|
m_Owner->RemoveDeliveryStatusSession (it->first);
|
||||||
it = m_UnconfirmedTagsMsgs.erase (it);
|
it = m_UnconfirmedTagsMsgs.erase (it);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
@@ -284,7 +274,7 @@ namespace garlic
|
|||||||
if (newTags) // new tags created
|
if (newTags) // new tags created
|
||||||
{
|
{
|
||||||
newTags->msgID = msgID;
|
newTags->msgID = msgID;
|
||||||
m_UnconfirmedTagsMsgs.emplace_back (newTags);
|
m_UnconfirmedTagsMsgs.emplace (msgID, std::unique_ptr<UnconfirmedTags>(newTags));
|
||||||
newTags = nullptr; // got acquired
|
newTags = nullptr; // got acquired
|
||||||
}
|
}
|
||||||
m_Owner->DeliveryStatusSent (shared_from_this (), msgID);
|
m_Owner->DeliveryStatusSent (shared_from_this (), msgID);
|
||||||
|
|||||||
2
Garlic.h
2
Garlic.h
@@ -131,7 +131,7 @@ namespace garlic
|
|||||||
i2p::crypto::AESKey m_SessionKey;
|
i2p::crypto::AESKey m_SessionKey;
|
||||||
std::list<SessionTag> m_SessionTags;
|
std::list<SessionTag> m_SessionTags;
|
||||||
int m_NumTags;
|
int m_NumTags;
|
||||||
std::list<std::unique_ptr<UnconfirmedTags> > m_UnconfirmedTagsMsgs;
|
std::map<uint32_t, std::unique_ptr<UnconfirmedTags> > m_UnconfirmedTagsMsgs; // msgID->tags
|
||||||
|
|
||||||
LeaseSetUpdateStatus m_LeaseSetUpdateStatus;
|
LeaseSetUpdateStatus m_LeaseSetUpdateStatus;
|
||||||
uint32_t m_LeaseSetUpdateMsgID;
|
uint32_t m_LeaseSetUpdateMsgID;
|
||||||
|
|||||||
Reference in New Issue
Block a user