@@ -3819,6 +3819,9 @@ bool ScraperSaveCScraperManifestToFiles(uint256 nManifestHash)
3819
3819
// This is from the map find above.
3820
3820
const CScraperManifest_shared_ptr manifest = pair->second ;
3821
3821
3822
+ LOCK (manifest->cs_manifest );
3823
+ _log (logattribute::INFO, " LOCK" , " cs_manifest" );
3824
+
3822
3825
// Write out to files the parts. Note this assumes one-to-one part to file. Needs to
3823
3826
// be fixed for more than one part per file.
3824
3827
int iPartNum = 0 ;
@@ -3859,6 +3862,7 @@ bool ScraperSaveCScraperManifestToFiles(uint256 nManifestHash)
3859
3862
iPartNum++;
3860
3863
}
3861
3864
3865
+ _log (logattribute::INFO, " ENDLOCK" , " cs_manifest" );
3862
3866
_log (logattribute::INFO, " ENDLOCK" , " CScraperManifest::cs_mapManifest" );
3863
3867
3864
3868
return true ;
@@ -4178,6 +4182,9 @@ unsigned int ScraperDeleteUnauthorizedCScraperManifests()
4178
4182
{
4179
4183
CScraperManifest_shared_ptr manifest = iter->second ;
4180
4184
4185
+ LOCK (manifest->cs_manifest );
4186
+ _log (logattribute::INFO, " LOCK" , " cs_manifest" );
4187
+
4181
4188
// We are not going to do anything with the banscore here, but it is an out parameter of IsManifestAuthorized.
4182
4189
unsigned int banscore_out = 0 ;
4183
4190
@@ -4194,6 +4201,8 @@ unsigned int ScraperDeleteUnauthorizedCScraperManifests()
4194
4201
iter = CScraperManifest::DeleteManifest (iter, true );
4195
4202
nDeleted++;
4196
4203
}
4204
+
4205
+ _log (logattribute::INFO, " ENDLOCK" , " cs_manifest" );
4197
4206
}
4198
4207
4199
4208
// End LOCK(CScraperManifest::cs_mapManifest)
@@ -4211,25 +4220,30 @@ bool ScraperSendFileManifestContents(CBitcoinAddress& Address, CKey& Key) EXCLUS
4211
4220
4212
4221
auto manifest = std::shared_ptr<CScraperManifest>(new CScraperManifest ());
4213
4222
4214
- // The manifest name is the authorized address of the scraper.
4215
- manifest->sCManifestName = Address.ToString ();
4216
-
4217
- // Also store local sCManifestName, because the manifest will be std::moved by addManifest.
4218
- std::string sCManifestName = Address.ToString ();
4219
-
4220
- manifest->nTime = StructScraperFileManifest.timestamp ;
4221
-
4222
- // Also store local nTime, because the manifest will be std::moved by addManifest.
4223
- int64_t nTime = StructScraperFileManifest.timestamp ;
4224
-
4225
- manifest->ConsensusBlock = StructScraperFileManifest.nConsensusBlockHash ;
4223
+ std::string sCManifestName ;
4224
+ int64_t nTime = 0 ;
4226
4225
4227
4226
// This will have to be changed to support files bigger than 32 MB, where more than one
4228
4227
// part per object will be required.
4229
4228
int iPartNum = 0 ;
4230
4229
4231
- // Inject the BeaconList part.
4232
4230
{
4231
+ LOCK2 (CSplitBlob::cs_mapParts, manifest->cs_manifest );
4232
+ _log (logattribute::INFO, " LOCK2" , " cs_mapParts, cs_manifest" );
4233
+
4234
+ // The manifest name is the authorized address of the scraper.
4235
+ manifest->sCManifestName = Address.ToString ();
4236
+
4237
+ // Also store local sCManifestName, because the manifest will be std::moved by addManifest.
4238
+ sCManifestName = Address.ToString ();
4239
+
4240
+ manifest->nTime = StructScraperFileManifest.timestamp ;
4241
+
4242
+ // Also store local nTime, because the manifest will be std::moved by addManifest.
4243
+ nTime = StructScraperFileManifest.timestamp ;
4244
+
4245
+ manifest->ConsensusBlock = StructScraperFileManifest.nConsensusBlockHash ;
4246
+
4233
4247
// Read in BeaconList
4234
4248
fs::path inputfile = " BeaconList.csv.gz" ;
4235
4249
fs::path inputfilewpath = pathScraper / inputfile;
@@ -4268,136 +4282,132 @@ bool ScraperSendFileManifestContents(CBitcoinAddress& Address, CKey& Key) EXCLUS
4268
4282
4269
4283
CDataStream part (std::move (vchData), SER_NETWORK, 1 );
4270
4284
4271
- LOCK (CSplitBlob::cs_mapParts);
4272
- _log (logattribute::INFO, " LOCK" , " cs_mapParts" );
4273
-
4274
4285
manifest->addPartData (std::move (part));
4275
4286
4276
4287
iPartNum++;
4277
4288
4278
- _log (logattribute::INFO, " ENDLOCK" , " cs_mapParts" );
4279
- }
4289
+ // Inject the VerifiedBeaconList as a "project" called VerifiedBeacons. This is inelegant, but
4290
+ // will maintain compatibility with older nodes. The older nodes will simply ignore this extra part
4291
+ // because it will never match any whitelisted project. Only include it if it is not empty.
4292
+ {
4293
+ LOCK (cs_VerifiedBeacons);
4294
+ _log (logattribute::INFO, " LOCK" , " cs_VerifiedBeacons" );
4280
4295
4281
- // Inject the VerifiedBeaconList as a "project" called VerifiedBeacons. This is inelegant, but
4282
- // will maintain compatibility with older nodes. The older nodes will simply ignore this extra part
4283
- // because it will never match any whitelisted project. Only include it if it is not empty.
4284
- {
4285
- LOCK (cs_VerifiedBeacons);
4286
- _log (logattribute::INFO, " LOCK" , " cs_VerifiedBeacons" );
4296
+ ScraperVerifiedBeacons& ScraperVerifiedBeacons = GetVerifiedBeacons ();
4287
4297
4288
- ScraperVerifiedBeacons& ScraperVerifiedBeacons = GetVerifiedBeacons ();
4298
+ if (!ScraperVerifiedBeacons.mVerifiedMap .empty ())
4299
+ {
4300
+ CScraperManifest::dentry ProjectEntry;
4289
4301
4290
- if (!ScraperVerifiedBeacons. mVerifiedMap . empty ())
4291
- {
4292
- CScraperManifest::dentry ProjectEntry;
4302
+ ProjectEntry. project = " VerifiedBeacons " ;
4303
+ ProjectEntry. LastModified = ScraperVerifiedBeacons. timestamp ;
4304
+ ProjectEntry. current = true ;
4293
4305
4294
- ProjectEntry.project = " VerifiedBeacons" ;
4295
- ProjectEntry.LastModified = ScraperVerifiedBeacons.timestamp ;
4296
- ProjectEntry.current = true ;
4306
+ // For now each object will only have one part.
4307
+ ProjectEntry.part1 = iPartNum;
4308
+ ProjectEntry.partc = 0 ;
4309
+ ProjectEntry.GridcoinTeamID = -1 ; // Not used anymore
4297
4310
4298
- // For now each object will only have one part.
4299
- ProjectEntry.part1 = iPartNum;
4300
- ProjectEntry.partc = 0 ;
4301
- ProjectEntry.GridcoinTeamID = -1 ; // Not used anymore
4311
+ ProjectEntry.last = 1 ;
4302
4312
4303
- ProjectEntry. last = 1 ;
4313
+ manifest-> projects . push_back (ProjectEntry) ;
4304
4314
4305
- manifest-> projects . push_back (ProjectEntry );
4315
+ CDataStream part (SER_NETWORK, 1 );
4306
4316
4307
- CDataStream part (SER_NETWORK, 1 ) ;
4317
+ part << ScraperVerifiedBeacons. mVerifiedMap ;
4308
4318
4309
- part << ScraperVerifiedBeacons.mVerifiedMap ;
4319
+ LOCK (CSplitBlob::cs_mapParts);
4320
+ _log (logattribute::INFO, " LOCK" , " cs_mapParts" );
4310
4321
4311
- LOCK (CSplitBlob::cs_mapParts);
4312
- _log (logattribute::INFO, " LOCK" , " cs_mapParts" );
4322
+ manifest->addPartData (std::move (part));
4313
4323
4314
- manifest-> addPartData ( std::move (part)) ;
4324
+ iPartNum++ ;
4315
4325
4316
- iPartNum++;
4326
+ _log (logattribute::INFO, " ENDLOCK" , " cs_mapParts" );
4327
+ }
4317
4328
4318
- _log (logattribute::INFO, " ENDLOCK" , " cs_mapParts " );
4329
+ _log (logattribute::INFO, " ENDLOCK" , " cs_VerifiedBeacons " );
4319
4330
}
4320
4331
4321
- _log (logattribute::INFO, " ENDLOCK" , " cs_VerifiedBeacons" );
4322
- }
4323
-
4332
+ for (auto const & entry : StructScraperFileManifest.mScraperFileManifest )
4333
+ {
4334
+ auto scraper_cmanifest_include_noncurrent_proj_files =
4335
+ []() { LOCK (cs_ScraperGlobals); return SCRAPER_CMANIFEST_INCLUDE_NONCURRENT_PROJ_FILES; };
4324
4336
4325
- for ( auto const & entry : StructScraperFileManifest. mScraperFileManifest )
4326
- {
4327
- auto scraper_cmanifest_include_noncurrent_proj_files =
4328
- []() { LOCK (cs_ScraperGlobals); return SCRAPER_CMANIFEST_INCLUDE_NONCURRENT_PROJ_FILES; } ;
4337
+ // If SCRAPER_CMANIFEST_INCLUDE_NONCURRENT_PROJ_FILES is false, only include current files to send across the network.
4338
+ // Also continue (exclude) if it is a non-publishable entry (excludefromcsmanifest is true).
4339
+ if ((! scraper_cmanifest_include_noncurrent_proj_files () && !entry. second . current ) || entry. second . excludefromcsmanifest )
4340
+ continue ;
4329
4341
4330
- // If SCRAPER_CMANIFEST_INCLUDE_NONCURRENT_PROJ_FILES is false, only include current files to send across the network.
4331
- // Also continue (exclude) if it is a non-publishable entry (excludefromcsmanifest is true).
4332
- if ((!scraper_cmanifest_include_noncurrent_proj_files () && !entry.second .current ) || entry.second .excludefromcsmanifest )
4333
- continue ;
4342
+ fs::path inputfile = entry.first ;
4334
4343
4335
- fs::path inputfile = entry. first ;
4344
+ // _log(logattribute::INFO, "ScraperSendFileManifestContents", "Input file for CScraperManifest is " + inputfile.string()) ;
4336
4345
4337
- // _log(logattribute::INFO, "ScraperSendFileManifestContents", "Input file for CScraperManifest is " + inputfile.string()) ;
4346
+ fs::path inputfilewpath = pathScraper / inputfile;
4338
4347
4339
- fs::path inputfilewpath = pathScraper / inputfile;
4348
+ // open input file, and associate with CAutoFile
4349
+ FILE *file = fsbridge::fopen (inputfilewpath, " rb" );
4350
+ CAutoFile filein (file, SER_DISK, CLIENT_VERSION);
4340
4351
4341
- // open input file, and associate with CAutoFile
4342
- FILE *file = fsbridge::fopen (inputfilewpath, " rb" );
4343
- CAutoFile filein (file, SER_DISK, CLIENT_VERSION);
4352
+ if (filein.IsNull ())
4353
+ {
4354
+ _log (logattribute::ERR, " ScraperSendFileManifestContents" , " Failed to open file (" + inputfile.string () + " )" );
4355
+ return false ;
4356
+ }
4344
4357
4345
- if (filein.IsNull ())
4346
- {
4347
- _log (logattribute::ERR, " ScraperSendFileManifestContents" , " Failed to open file (" + inputfile.string () + " )" );
4348
- return false ;
4349
- }
4358
+ // use file size to size memory buffer
4359
+ int dataSize = fs::file_size (inputfilewpath);
4360
+ std::vector<unsigned char > vchData;
4361
+ vchData.resize (dataSize);
4350
4362
4351
- // use file size to size memory buffer
4352
- int dataSize = fs::file_size (inputfilewpath);
4353
- std::vector<unsigned char > vchData;
4354
- vchData.resize (dataSize);
4363
+ // read data from file
4364
+ try
4365
+ {
4366
+ filein.read ((char *)&vchData[0 ], dataSize);
4367
+ }
4368
+ catch (std::exception &e)
4369
+ {
4370
+ _log (logattribute::ERR, " ScraperSendFileManifestContents" , " Failed to read file (" + inputfile.string () + " )" );
4371
+ return false ;
4372
+ }
4355
4373
4356
- // read data from file
4357
- try
4358
- {
4359
- filein.read ((char *)&vchData[0 ], dataSize);
4360
- }
4361
- catch (std::exception &e)
4362
- {
4363
- _log (logattribute::ERR, " ScraperSendFileManifestContents" , " Failed to read file (" + inputfile.string () + " )" );
4364
- return false ;
4365
- }
4374
+ filein.fclose ();
4366
4375
4367
- filein.fclose ();
4368
4376
4377
+ CScraperManifest::dentry ProjectEntry;
4369
4378
4370
- CScraperManifest::dentry ProjectEntry;
4379
+ ProjectEntry.project = entry.second .project ;
4380
+ std::string sProject = entry.second .project + " -" ;
4371
4381
4372
- ProjectEntry. project = entry. second . project ;
4373
- std::string sProject = entry. second . project + " - " ;
4382
+ std::string sinputfile = inputfile. string () ;
4383
+ std::string suffix = " .csv.gz " ;
4374
4384
4375
- std::string sinputfile = inputfile.string ();
4376
- std::string suffix = " .csv.gz" ;
4385
+ // Remove project-
4386
+ sinputfile.erase (sinputfile.find (sProject ), sProject .length ());
4387
+ // Remove suffix. What is left is the ETag.
4388
+ ProjectEntry.ETag = sinputfile.erase (sinputfile.find (suffix), suffix.length ());
4377
4389
4378
- // Remove project-
4379
- sinputfile.erase (sinputfile.find (sProject ), sProject .length ());
4380
- // Remove suffix. What is left is the ETag.
4381
- ProjectEntry.ETag = sinputfile.erase (sinputfile.find (suffix), suffix.length ());
4390
+ ProjectEntry.LastModified = entry.second .timestamp ;
4382
4391
4383
- ProjectEntry.LastModified = entry.second .timestamp ;
4392
+ // For now each object will only have one part.
4393
+ ProjectEntry.part1 = iPartNum;
4394
+ ProjectEntry.partc = 0 ;
4395
+ ProjectEntry.GridcoinTeamID = -1 ; // Not used anymore
4384
4396
4385
- // For now each object will only have one part.
4386
- ProjectEntry.part1 = iPartNum;
4387
- ProjectEntry.partc = 0 ;
4388
- ProjectEntry.GridcoinTeamID = -1 ; // Not used anymore
4397
+ ProjectEntry.current = entry.second .current ;
4389
4398
4390
- ProjectEntry.current = entry. second . current ;
4399
+ ProjectEntry.last = 1 ;
4391
4400
4392
- ProjectEntry. last = 1 ;
4401
+ manifest-> projects . push_back (ProjectEntry) ;
4393
4402
4394
- manifest-> projects . push_back (ProjectEntry );
4403
+ CDataStream part (vchData, SER_NETWORK, 1 );
4395
4404
4396
- CDataStream part (vchData, SER_NETWORK, 1 );
4405
+ manifest-> addPartData ( std::move (part) );
4397
4406
4398
- manifest->addPartData (std::move (part));
4407
+ iPartNum++;
4408
+ }
4399
4409
4400
- iPartNum++ ;
4410
+ _log (logattribute::INFO, " ENDLOCK2 " , " cs_mapParts, cs_manifest " ) ;
4401
4411
}
4402
4412
4403
4413
// "Sign" and "send".
@@ -4447,6 +4457,9 @@ ConvergedManifest::ConvergedManifest()
4447
4457
4448
4458
ConvergedManifest::ConvergedManifest (CScraperManifest_shared_ptr& in)
4449
4459
{
4460
+ // Make Clang happy.
4461
+ LOCK (in->cs_manifest );
4462
+
4450
4463
ConsensusBlock = in->ConsensusBlock ;
4451
4464
timestamp = GetAdjustedTime ();
4452
4465
bByParts = false ;
@@ -4462,6 +4475,8 @@ ConvergedManifest::ConvergedManifest(CScraperManifest_shared_ptr& in)
4462
4475
4463
4476
bool ConvergedManifest::operator ()(const CScraperManifest_shared_ptr& in)
4464
4477
{
4478
+ LOCK (in->cs_manifest );
4479
+
4465
4480
ConsensusBlock = in->ConsensusBlock ;
4466
4481
timestamp = GetAdjustedTime ();
4467
4482
bByParts = false ;
0 commit comments