From 1caacaacf080028905b92f0779fbe024727aa50e Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 18 Mar 2015 15:36:07 -0400 Subject: [PATCH] UpdateStats for RouterContext --- NetDb.cpp | 1 + RouterContext.cpp | 17 +++++++++++------ RouterContext.h | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/NetDb.cpp b/NetDb.cpp index 9655b6c3..2f30890b 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -861,6 +861,7 @@ namespace data void NetDb::Publish () { + i2p::context.UpdateStats (); std::set excluded; // TODO: fill up later for (int i = 0; i < 2; i++) { diff --git a/RouterContext.cpp b/RouterContext.cpp index 681ca29f..c524486d 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -56,12 +56,6 @@ namespace i2p void RouterContext::UpdateRouterInfo () { - if (m_IsFloodfill) - { - // update routers and leasesets - m_RouterInfo.SetProperty (ROUTER_INFO_PROPERTY_LEASESETS, boost::lexical_cast(i2p::data::netdb.GetNumLeaseSets ())); - m_RouterInfo.SetProperty (ROUTER_INFO_PROPERTY_ROUTERS, boost::lexical_cast(i2p::data::netdb.GetNumRouters ())); - } m_RouterInfo.CreateBuffer (m_Keys); m_RouterInfo.SaveToFile (i2p::util::filesystem::GetFullPath (ROUTER_INFO)); m_LastUpdateTime = i2p::util::GetSecondsSinceEpoch (); @@ -233,6 +227,17 @@ namespace i2p if (updated) UpdateRouterInfo (); } + + void RouterContext::UpdateStats () + { + if (m_IsFloodfill) + { + // update routers and leasesets + m_RouterInfo.SetProperty (ROUTER_INFO_PROPERTY_LEASESETS, boost::lexical_cast(i2p::data::netdb.GetNumLeaseSets ())); + m_RouterInfo.SetProperty (ROUTER_INFO_PROPERTY_ROUTERS, boost::lexical_cast(i2p::data::netdb.GetNumRouters ())); + UpdateRouterInfo (); + } + } bool RouterContext::Load () { diff --git a/RouterContext.h b/RouterContext.h index 1003f6cf..483f3feb 100644 --- a/RouterContext.h +++ b/RouterContext.h @@ -60,7 +60,8 @@ namespace i2p void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; }; bool SupportsV6 () const { return m_RouterInfo.IsV6 (); }; void SetSupportsV6 (bool supportsV6); - void UpdateNTCPV6Address (const boost::asio::ip::address& host); // called from NTCP session + void UpdateNTCPV6Address (const boost::asio::ip::address& host); // called from NTCP session + void UpdateStats (); // implements LocalDestination const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };