Skip to content

Commit 635141e

Browse files
committed
Manifest age check when requesting parts
This is an additional check that should eliminate the spurious part problem.
1 parent 70a9b4c commit 635141e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/scraper_net.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ std::map<uint256, std::pair<int64_t, std::unique_ptr<CScraperManifest>>> CScrape
2424
CCriticalSection CScraperManifest::cs_mapManifest;
2525
extern unsigned int SCRAPER_MISBEHAVING_NODE_BANSCORE;
2626
extern int64_t SCRAPER_DEAUTHORIZED_BANSCORE_GRACE_PERIOD;
27+
extern int64_t SCRAPER_CMANIFEST_RETENTION_TIME;
2728
extern unsigned int nScraperSleep;
2829
extern AppCacheSectionExt mScrapersExt;
2930
extern std::atomic<int64_t> nSyncTime;
@@ -546,7 +547,10 @@ bool CScraperManifest::RecvManifest(CNode* pfrom, CDataStream& vRecv)
546547
manifest.Complete();
547548
} else {
548549
/* else request missing parts from the sender */
549-
manifest.UseAsSource(pfrom);
550+
// Note: As an additional buffer to prevent spurious part receipts, if the manifest timestamp is within nScraperSleep of expiration (i.e.
551+
// about to go on the pending delete list, then do not request missing parts, as it is possible that the manifest will be deleted
552+
// by the housekeeping loop in between the receipt of the manifest, request for parts, and receipt of parts otherwise.
553+
if (manifest.nTime >= GetAdjustedTime() - SCRAPER_CMANIFEST_RETENTION_TIME + (int64_t) nScraperSleep / 1000) manifest.UseAsSource(pfrom);
550554
}
551555
return true;
552556
}

0 commit comments

Comments
 (0)