From 2f0dba1044fc3578ea8e8954417f50d0df5970c1 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 7 Jan 2025 22:30:19 +0100 Subject: [PATCH] limit provided history by first seen --- src/solanaceae/zox/ngc_hs.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/solanaceae/zox/ngc_hs.cpp b/src/solanaceae/zox/ngc_hs.cpp index 47989eb..623db44 100644 --- a/src/solanaceae/zox/ngc_hs.cpp +++ b/src/solanaceae/zox/ngc_hs.cpp @@ -271,7 +271,12 @@ bool ZoxNGCHistorySync::onEvent(const Events::ZoxNGC_ngch_request& e) { // convert sync delta to ms const int64_t sync_delta_offset_ms = int64_t(e.sync_delta) * 1000 * 60; - const uint64_t ts_start = getTimeMS() - sync_delta_offset_ms; + uint64_t ts_start = getTimeMS() - sync_delta_offset_ms; + + // make sure we dont sync past the peers first appearance + if (const auto first_seen_ptr = request_sender.try_get(); first_seen_ptr != nullptr) { + ts_start = std::max(ts_start, first_seen_ptr->ts); + } auto view = reg.view(); for (auto it = view.rbegin(), it_end = view.rend(); it != it_end; it++) {