From c69c4ae8a019d3d220a522797d0987877bd9da9e Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 15 Nov 2020 21:46:49 -0500 Subject: [PATCH] don't publish too fast --- libi2pd/NetDb.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libi2pd/NetDb.cpp b/libi2pd/NetDb.cpp index 9a90e952..4399fb15 100644 --- a/libi2pd/NetDb.cpp +++ b/libi2pd/NetDb.cpp @@ -151,14 +151,22 @@ namespace data lastDestinationCleanup = ts; } - if (!m_HiddenMode && i2p::transport::transports.IsOnline () && - ((m_PublishReplyToken && ts - lastPublish >= NETDB_PUBLISH_CONFIRMATION_TIMEOUT) || - i2p::context.GetLastUpdateTime () > lastPublish || - ts - lastPublish >= NETDB_PUBLISH_INTERVAL)) // update timestamp and publish + // publish + if (!m_HiddenMode && i2p::transport::transports.IsOnline ()) { - i2p::context.UpdateTimestamp (ts); - Publish (); - lastPublish = ts; + bool publish = false; + if (m_PublishReplyToken) + { + if (ts - lastPublish >= NETDB_PUBLISH_CONFIRMATION_TIMEOUT) publish = true; + } + else if (i2p::context.GetLastUpdateTime () > lastPublish || + ts - lastPublish >= NETDB_PUBLISH_INTERVAL) publish = true; + if (publish) // update timestamp and publish + { + i2p::context.UpdateTimestamp (ts); + Publish (); + lastPublish = ts; + } } if (ts - lastExploratory >= 30) // exploratory every 30 seconds {