@@ -2240,68 +2240,6 @@ void ThreadScriptCheck() {
2240
2240
scriptcheckqueue.Thread ();
2241
2241
}
2242
2242
2243
- //
2244
- // Called periodically asynchronously; alerts if it smells like
2245
- // we're being fed a bad chain (blocks being generated much
2246
- // too slowly or too quickly).
2247
- //
2248
- void PartitionCheck (bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader,
2249
- int64_t nPowTargetSpacing)
2250
- {
2251
- if (bestHeader == NULL || initialDownloadCheck ()) return ;
2252
-
2253
- static int64_t lastAlertTime = 0 ;
2254
- int64_t now = GetAdjustedTime ();
2255
- if (lastAlertTime > now-60 *60 *24 ) return ; // Alert at most once per day
2256
-
2257
- const int SPAN_HOURS=4 ;
2258
- const int SPAN_SECONDS=SPAN_HOURS*60 *60 ;
2259
- int BLOCKS_EXPECTED = SPAN_SECONDS / nPowTargetSpacing;
2260
-
2261
- boost::math::poisson_distribution<double > poisson (BLOCKS_EXPECTED);
2262
-
2263
- std::string strWarning;
2264
- int64_t startTime = GetAdjustedTime ()-SPAN_SECONDS;
2265
-
2266
- LOCK (cs);
2267
- const CBlockIndex* i = bestHeader;
2268
- int nBlocks = 0 ;
2269
- while (i->GetBlockTime () >= startTime) {
2270
- ++nBlocks;
2271
- i = i->pprev ;
2272
- if (i == NULL ) return ; // Ran out of chain, we must not be fully sync'ed
2273
- }
2274
-
2275
- // How likely is it to find that many by chance?
2276
- double p = boost::math::pdf (poisson, nBlocks);
2277
-
2278
- LogPrint (" partitioncheck" , " %s: Found %d blocks in the last %d hours\n " , __func__, nBlocks, SPAN_HOURS);
2279
- LogPrint (" partitioncheck" , " %s: likelihood: %g\n " , __func__, p);
2280
-
2281
- // Aim for one false-positive about every fifty years of normal running:
2282
- const int FIFTY_YEARS = 50 *365 *24 *60 *60 ;
2283
- double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS);
2284
-
2285
- if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED)
2286
- {
2287
- // Many fewer blocks than expected: alert!
2288
- strWarning = strprintf (_ (" WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)" ),
2289
- nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
2290
- }
2291
- else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED)
2292
- {
2293
- // Many more blocks than expected: alert!
2294
- strWarning = strprintf (_ (" WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)" ),
2295
- nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
2296
- }
2297
- if (!strWarning.empty ())
2298
- {
2299
- strMiscWarning = strWarning;
2300
- AlertNotify (strWarning);
2301
- lastAlertTime = now;
2302
- }
2303
- }
2304
-
2305
2243
// Protected by cs_main
2306
2244
VersionBitsCache versionbitscache;
2307
2245
0 commit comments