From acd6af709ee6371b3d0340d2c92cb86f6f4bcb97 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 5 Jan 2023 18:16:36 -0500 Subject: [PATCH] don't use netdb memory pool for local RouterInfo --- libi2pd/RouterInfo.cpp | 26 +++++++++++++++++++++++--- libi2pd/RouterInfo.h | 6 +++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp index 4667be98..1aa0259b 100644 --- a/libi2pd/RouterInfo.cpp +++ b/libi2pd/RouterInfo.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2022, The PurpleI2P Project +* Copyright (c) 2013-2023, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -206,13 +206,13 @@ namespace data s.read ((char *)&m_Timestamp, sizeof (m_Timestamp)); m_Timestamp = be64toh (m_Timestamp); // read addresses - auto addresses = netdb.NewRouterInfoAddresses (); + auto addresses = NewAddresses (); uint8_t numAddresses; s.read ((char *)&numAddresses, sizeof (numAddresses)); for (int i = 0; i < numAddresses; i++) { uint8_t supportedTransports = 0; - auto address = netdb.NewRouterInfoAddress (); + auto address = NewAddress (); uint8_t cost; // ignore s.read ((char *)&cost, sizeof (cost)); s.read ((char *)&address->date, sizeof (address->date)); @@ -974,6 +974,16 @@ namespace data return netdb.NewRouterInfoBuffer (); } + std::shared_ptr RouterInfo::NewAddress () const + { + return netdb.NewRouterInfoAddress (); + } + + boost::shared_ptr RouterInfo::NewAddresses () const + { + return netdb.NewRouterInfoAddresses (); + } + void RouterInfo::RefreshTimestamp () { m_Timestamp = i2p::util::GetMillisecondsSinceEpoch (); @@ -1255,6 +1265,16 @@ namespace data return std::make_shared (); } + std::shared_ptr LocalRouterInfo::NewAddress () const + { + return std::make_shared
(); + } + + boost::shared_ptr LocalRouterInfo::NewAddresses () const + { + return boost::make_shared (); + } + bool LocalRouterInfo::AddSSU2Introducer (const Introducer& introducer, bool v4) { auto addresses = GetAddresses (); diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h index 5008b5b1..4e54d615 100644 --- a/libi2pd/RouterInfo.h +++ b/libi2pd/RouterInfo.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2022, The PurpleI2P Project +* Copyright (c) 2013-2023, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -285,6 +285,8 @@ namespace data template std::shared_ptr GetAddress (Filter filter) const; virtual std::shared_ptr NewBuffer () const; + virtual std::shared_ptr
NewAddress () const; + virtual boost::shared_ptr NewAddresses () const; private: @@ -324,6 +326,8 @@ namespace data void UpdateCapsProperty (); void WriteString (const std::string& str, std::ostream& s) const; std::shared_ptr NewBuffer () const override; + std::shared_ptr
NewAddress () const override; + boost::shared_ptr NewAddresses () const override; private: