Browse Source

use unordered_map for incomplete and sent messages

pull/1550/head
orignal 4 years ago
parent
commit
8e25226574
  1. 2
      libi2pd/SSUData.cpp
  2. 6
      libi2pd/SSUData.h

2
libi2pd/SSUData.cpp

@ -301,7 +301,7 @@ namespace transport
void SSUData::Send (std::shared_ptr<i2p::I2NPMessage> msg) void SSUData::Send (std::shared_ptr<i2p::I2NPMessage> msg)
{ {
uint32_t msgID = msg->ToSSU (); uint32_t msgID = msg->ToSSU ();
if (m_SentMessages.count (msgID) > 0) if (m_SentMessages.find (msgID) != m_SentMessages.end())
{ {
LogPrint (eLogWarning, "SSU: message ", msgID, " already sent"); LogPrint (eLogWarning, "SSU: message ", msgID, " already sent");
return; return;

6
libi2pd/SSUData.h

@ -11,7 +11,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <string.h> #include <string.h>
#include <map> #include <unordered_map>
#include <vector> #include <vector>
#include <unordered_set> #include <unordered_set>
#include <memory> #include <memory>
@ -124,8 +124,8 @@ namespace transport
private: private:
SSUSession& m_Session; SSUSession& m_Session;
std::map<uint32_t, std::unique_ptr<IncompleteMessage> > m_IncompleteMessages; std::unordered_map<uint32_t, std::unique_ptr<IncompleteMessage> > m_IncompleteMessages;
std::map<uint32_t, std::unique_ptr<SentMessage> > m_SentMessages; std::unordered_map<uint32_t, std::unique_ptr<SentMessage> > m_SentMessages;
std::unordered_set<uint32_t> m_ReceivedMessages; std::unordered_set<uint32_t> m_ReceivedMessages;
boost::asio::deadline_timer m_ResendTimer, m_IncompleteMessagesCleanupTimer; boost::asio::deadline_timer m_ResendTimer, m_IncompleteMessagesCleanupTimer;
int m_MaxPacketSize, m_PacketSize; int m_MaxPacketSize, m_PacketSize;

Loading…
Cancel
Save