Browse Source

reduce memory usage

pull/163/head
orignal 10 years ago
parent
commit
c7edc36106
  1. 6
      NetDb.cpp
  2. 8
      RouterInfo.cpp
  3. 4
      RouterInfo.h

6
NetDb.cpp

@ -356,6 +356,7 @@ namespace data
if (!r->IsUnreachable () && (!r->UsesIntroducer () || ts < r->GetTimestamp () + 3600*1000LL)) // 1 hour if (!r->IsUnreachable () && (!r->UsesIntroducer () || ts < r->GetTimestamp () + 3600*1000LL)) // 1 hour
{ {
r->DeleteBuffer (); r->DeleteBuffer ();
r->ClearProperties (); // properties are not used for regular routers
m_RouterInfos[r->GetIdentHash ()] = r; m_RouterInfos[r->GetIdentHash ()] = r;
if (r->IsFloodfill ()) if (r->IsFloodfill ())
m_Floodfills.push_back (r); m_Floodfills.push_back (r);
@ -566,9 +567,14 @@ namespace data
decompressor.MessageEnd(); decompressor.MessageEnd();
uint8_t uncompressed[2048]; uint8_t uncompressed[2048];
size_t uncomressedSize = decompressor.MaxRetrievable (); size_t uncomressedSize = decompressor.MaxRetrievable ();
if (uncomressedSize <= 2048)
{
decompressor.Get (uncompressed, uncomressedSize); decompressor.Get (uncompressed, uncomressedSize);
AddRouterInfo (buf + DATABASE_STORE_KEY_OFFSET, uncompressed, uncomressedSize); AddRouterInfo (buf + DATABASE_STORE_KEY_OFFSET, uncompressed, uncomressedSize);
} }
else
LogPrint ("Invalid RouterInfo uncomressed length ", (int)uncomressedSize);
}
catch (CryptoPP::Exception& ex) catch (CryptoPP::Exception& ex)
{ {
LogPrint (eLogError, "DatabaseStore: ", ex.what ()); LogPrint (eLogError, "DatabaseStore: ", ex.what ());

8
RouterInfo.cpp

@ -553,14 +553,6 @@ namespace data
m_Properties[key] = value; m_Properties[key] = value;
} }
const char * RouterInfo::GetProperty (const char * key) const
{
auto it = m_Properties.find (key);
if (it != m_Properties.end ())
return it->second.c_str ();
return 0;
}
bool RouterInfo::IsFloodfill () const bool RouterInfo::IsFloodfill () const
{ {
return m_Caps & Caps::eFloodfill; return m_Caps & Caps::eFloodfill;

4
RouterInfo.h

@ -105,8 +105,8 @@ namespace data
void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0); void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0);
bool AddIntroducer (const Address * address, uint32_t tag); bool AddIntroducer (const Address * address, uint32_t tag);
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e); bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
void SetProperty (const char * key, const char * value); void SetProperty (const char * key, const char * value); // called from RouterContext only
const char * GetProperty (const char * key) const; void ClearProperties () { m_Properties.clear (); };
bool IsFloodfill () const; bool IsFloodfill () const;
bool IsNTCP (bool v4only = true) const; bool IsNTCP (bool v4only = true) const;
bool IsSSU (bool v4only = true) const; bool IsSSU (bool v4only = true) const;

Loading…
Cancel
Save