From 39b2f82c24c34df26c5c71f0bd3ddd771f443658 Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 3 Oct 2026 22:08:44 -0400 Subject: [PATCH] retry publishing LeaseSet if no floodfills or tunnels --- libi2pd/Destination.cpp | 21 ++++++++++++++------- libi2pd/Destination.h | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index 4e900031..5463377f 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -666,6 +666,8 @@ namespace client { LogPrint (eLogError, "Destination: Can't publish LeaseSet, no more floodfills found"); m_ExcludedFloodfills.clear (); + // try again later + SchedulePublishRetry (); return; } auto outbound = m_Pool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false)); @@ -698,13 +700,8 @@ namespace client if (!floodfill || !outbound || !inbound) { // we can't publish now - m_ExcludedFloodfills.clear (); - m_PublishReplyToken = 1; // dummy non-zero value - // try again after a while - LogPrint (eLogInfo, "Destination: Can't publish LeaseSet because destination is not ready. Try publishing again after ", PUBLISH_CONFIRMATION_TIMEOUT, " milliseconds"); - m_PublishConfirmationTimer.expires_after (std::chrono::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT)); - m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer, - shared_from_this (), std::placeholders::_1, PUBLISH_CONFIRMATION_TIMEOUT)); + // try again layer + SchedulePublishRetry (); return; } } @@ -733,6 +730,16 @@ namespace client m_LastSubmissionTime = ts; } + void LeaseSetDestination::SchedulePublishRetry () + { + m_ExcludedFloodfills.clear (); + m_PublishReplyToken = 1; // dummy non-zero value + LogPrint (eLogInfo, "Destination: Can't publish LeaseSet because destination is not ready. Try publishing again after ", PUBLISH_CONFIRMATION_TIMEOUT, " milliseconds"); + m_PublishConfirmationTimer.expires_after (std::chrono::milliseconds(PUBLISH_RETRY_INTERVAL)); + m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer, + shared_from_this (), std::placeholders::_1, PUBLISH_RETRY_INTERVAL)); + } + void LeaseSetDestination::HandlePublishConfirmationTimer (const boost::system::error_code& ecode, uint64_t publishConfirmationTimeout) { if (ecode != boost::asio::error::operation_aborted) diff --git a/libi2pd/Destination.h b/libi2pd/Destination.h index 4e1634fe..79d8eac5 100644 --- a/libi2pd/Destination.h +++ b/libi2pd/Destination.h @@ -43,6 +43,7 @@ namespace client const uint8_t PROTOCOL_TYPE_DATAGRAM2 = 19; const uint8_t PROTOCOL_TYPE_DATAGRAM3 = 20; const int PUBLISH_CONFIRMATION_TIMEOUT = 1400; // in milliseconds + const int PUBLISH_RETRY_INTERVAL = 11200; // in milliseconds const int PUBLISH_VERIFICATION_TIMEOUT = 5; // in seconds after successful publish const int PUBLISH_VERIFICATION_TIMEOUT_VARIANCE = 3; // in seconds const int PUBLISH_MIN_INTERVAL = 20; // in seconds @@ -196,6 +197,7 @@ namespace client std::shared_ptr GetLeaseSetMt (); void Publish (); + void SchedulePublishRetry (); void HandlePublishConfirmationTimer (const boost::system::error_code& ecode, uint64_t publishConfirmationTimeout); void HandlePublishVerificationTimer (const boost::system::error_code& ecode); void HandlePublishDelayTimer (const boost::system::error_code& ecode);