Skip to content

Commit fb18269

Browse files
committed
Further lock adjustments and put in missed IsComplete()
1 parent c64a17e commit fb18269

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

src/scraper/scraper.cpp

+16-29
Original file line numberDiff line numberDiff line change
@@ -4704,14 +4704,6 @@ bool ScraperConstructConvergedManifestByProject(const NN::WhitelistSnapshot& pro
47044704
_log(logattribute::INFO, "ENDLOCK", "CSplitBlob::cs_mapParts");
47054705
}
47064706

4707-
/*
4708-
4709-
// The ConvergedManifest content hash is in the order of the map key and on the data.
4710-
for (const auto& iter : StructConvergedManifest.ConvergedManifestPartPtrsMap)
4711-
ss << iter.second->data;
4712-
4713-
StructConvergedManifest.nContentHash = Hash(ss.begin(), ss.end());
4714-
*/
47154707
StructConvergedManifest.ComputeConvergedContentHash();
47164708

47174709
StructConvergedManifest.timestamp = GetAdjustedTime();
@@ -4809,6 +4801,9 @@ mmCSManifestsBinnedByScraper BinCScraperManifestsByScraper()
48094801
{
48104802
CScraperManifest& manifest = *iter->second;
48114803

4804+
// Do not consider manifests that do not have all of their parts.
4805+
if (!manifest.isComplete()) continue;
4806+
48124807
std::string sManifestName = manifest.sCManifestName;
48134808
int64_t nTime = manifest.nTime;
48144809
uint256 nHash = *manifest.phash;
@@ -4843,7 +4838,7 @@ mmCSManifestsBinnedByScraper ScraperCullAndBinCScraperManifests()
48434838

48444839
_log(logattribute::INFO, "ScraperDeleteCScraperManifests", "Deleting old CScraperManifests.");
48454840

4846-
LOCK2(CScraperManifest::cs_mapManifest, CSplitBlob::cs_mapParts);
4841+
LOCK(CScraperManifest::cs_mapManifest);
48474842
_log(logattribute::INFO, "LOCK", "CScraperManifest::cs_mapManifest");
48484843

48494844
// First check for unauthorized manifests just in case a scraper has been deauthorized.
@@ -4924,7 +4919,7 @@ mmCSManifestsBinnedByScraper ScraperCullAndBinCScraperManifests()
49244919
// that large. (The lock on CScraperManifest::cs_mapManifest is still held from above.)
49254920
mMapCSManifestsBinnedByScraper = BinCScraperManifestsByScraper();
49264921

4927-
_log(logattribute::INFO, "ENDLOCK2", "CScraperManifest::cs_mapManifest, CSplitBlob::cs_mapParts");
4922+
_log(logattribute::INFO, "ENDLOCK", "CScraperManifest::cs_mapManifest");
49284923

49294924
return mMapCSManifestsBinnedByScraper;
49304925
}
@@ -4934,29 +4929,21 @@ mmCSManifestsBinnedByScraper ScraperCullAndBinCScraperManifests()
49344929
// ---------------------------------------------- In ---------------------------------------- Out
49354930
bool LoadBeaconListFromConvergedManifest(const ConvergedManifest& StructConvergedManifest, ScraperBeaconMap& mBeaconMap)
49364931
{
4937-
boostio::filtering_istream in;
4932+
// Find the beacon list.
4933+
auto iter = StructConvergedManifest.ConvergedManifestPartPtrsMap.find("BeaconList");
49384934

4935+
// Bail if the beacon list is not found, or the part is zero size (missing referenced part)
4936+
if (iter == StructConvergedManifest.ConvergedManifestPartPtrsMap.end() || iter->second->data.size() == 0)
49394937
{
4940-
LOCK(CSplitBlob::cs_mapParts);
4941-
_log(logattribute::INFO, "LOCK", "CSplitBlob::cs_mapParts");
4942-
4943-
// Find the beacon list.
4944-
auto iter = StructConvergedManifest.ConvergedManifestPartPtrsMap.find("BeaconList");
4945-
4946-
// Bail if the beacon list is not found, or the part is zero size (missing referenced part)
4947-
if (iter == StructConvergedManifest.ConvergedManifestPartPtrsMap.end() || iter->second->data.size() == 0)
4948-
{
4949-
return false;
4950-
}
4951-
4952-
boostio::basic_array_source<char> input_source(&iter->second->data[0], iter->second->data.size());
4953-
boostio::stream<boostio::basic_array_source<char>> ingzss(input_source);
4938+
return false;
4939+
}
49544940

4955-
in.push(boostio::gzip_decompressor());
4956-
in.push(ingzss);
4941+
boostio::basic_array_source<char> input_source(&iter->second->data[0], iter->second->data.size());
4942+
boostio::stream<boostio::basic_array_source<char>> ingzss(input_source);
49574943

4958-
_log(logattribute::INFO, "ENDLOCK", "CSplitBlob::cs_mapParts");
4959-
}
4944+
boostio::filtering_istream in;
4945+
in.push(boostio::gzip_decompressor());
4946+
in.push(ingzss);
49604947

49614948
std::string line;
49624949

0 commit comments

Comments
 (0)