@@ -2118,68 +2118,6 @@ void ThreadScriptCheck() {
2118
2118
scriptcheckqueue.Thread ();
2119
2119
}
2120
2120
2121
- //
2122
- // Called periodically asynchronously; alerts if it smells like
2123
- // we're being fed a bad chain (blocks being generated much
2124
- // too slowly or too quickly).
2125
- //
2126
- void PartitionCheck (bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader,
2127
- int64_t nPowTargetSpacing)
2128
- {
2129
- if (bestHeader == NULL || initialDownloadCheck ()) return ;
2130
-
2131
- static int64_t lastAlertTime = 0 ;
2132
- int64_t now = GetAdjustedTime ();
2133
- if (lastAlertTime > now-60 *60 *24 ) return ; // Alert at most once per day
2134
-
2135
- const int SPAN_HOURS=4 ;
2136
- const int SPAN_SECONDS=SPAN_HOURS*60 *60 ;
2137
- int BLOCKS_EXPECTED = SPAN_SECONDS / nPowTargetSpacing;
2138
-
2139
- boost::math::poisson_distribution<double > poisson (BLOCKS_EXPECTED);
2140
-
2141
- std::string strWarning;
2142
- int64_t startTime = GetAdjustedTime ()-SPAN_SECONDS;
2143
-
2144
- LOCK (cs);
2145
- const CBlockIndex* i = bestHeader;
2146
- int nBlocks = 0 ;
2147
- while (i->GetBlockTime () >= startTime) {
2148
- ++nBlocks;
2149
- i = i->pprev ;
2150
- if (i == NULL ) return ; // Ran out of chain, we must not be fully sync'ed
2151
- }
2152
-
2153
- // How likely is it to find that many by chance?
2154
- double p = boost::math::pdf (poisson, nBlocks);
2155
-
2156
- LogPrint (" partitioncheck" , " %s: Found %d blocks in the last %d hours\n " , __func__, nBlocks, SPAN_HOURS);
2157
- LogPrint (" partitioncheck" , " %s: likelihood: %g\n " , __func__, p);
2158
-
2159
- // Aim for one false-positive about every fifty years of normal running:
2160
- const int FIFTY_YEARS = 50 *365 *24 *60 *60 ;
2161
- double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS);
2162
-
2163
- if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED)
2164
- {
2165
- // Many fewer blocks than expected: alert!
2166
- strWarning = strprintf (_ (" WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)" ),
2167
- nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
2168
- }
2169
- else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED)
2170
- {
2171
- // Many more blocks than expected: alert!
2172
- strWarning = strprintf (_ (" WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)" ),
2173
- nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
2174
- }
2175
- if (!strWarning.empty ())
2176
- {
2177
- strMiscWarning = strWarning;
2178
- AlertNotify (strWarning);
2179
- lastAlertTime = now;
2180
- }
2181
- }
2182
-
2183
2121
// Protected by cs_main
2184
2122
VersionBitsCache versionbitscache;
2185
2123
0 commit comments