@@ -1864,6 +1864,16 @@ void PruneAndFlush() {
1864
1864
FlushStateToDisk (state, FLUSH_STATE_NONE);
1865
1865
}
1866
1866
1867
+ static void DoWarning (const std::string& strWarning)
1868
+ {
1869
+ static bool fWarned = false ;
1870
+ SetMiscWarning (strWarning);
1871
+ if (!fWarned ) {
1872
+ AlertNotify (strWarning);
1873
+ fWarned = true ;
1874
+ }
1875
+ }
1876
+
1867
1877
/* * Update chainActive and related internal data structures. */
1868
1878
void static UpdateTip (CBlockIndex *pindexNew, const CChainParams& chainParams) {
1869
1879
chainActive.SetTip (pindexNew);
@@ -1873,7 +1883,6 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
1873
1883
1874
1884
cvBlockChange.notify_all ();
1875
1885
1876
- static bool fWarned = false ;
1877
1886
std::vector<std::string> warningMessages;
1878
1887
if (!IsInitialBlockDownload ())
1879
1888
{
@@ -1883,15 +1892,11 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
1883
1892
WarningBitsConditionChecker checker (bit);
1884
1893
ThresholdState state = checker.GetStateFor (pindex, chainParams.GetConsensus (), warningcache[bit]);
1885
1894
if (state == THRESHOLD_ACTIVE || state == THRESHOLD_LOCKED_IN) {
1895
+ const std::string strWarning = strprintf (_ (" Warning: unknown new rules activated (versionbit %i)" ), bit);
1886
1896
if (state == THRESHOLD_ACTIVE) {
1887
- std::string strWarning = strprintf (_ (" Warning: unknown new rules activated (versionbit %i)" ), bit);
1888
- SetMiscWarning (strWarning);
1889
- if (!fWarned ) {
1890
- AlertNotify (strWarning);
1891
- fWarned = true ;
1892
- }
1897
+ DoWarning (strWarning);
1893
1898
} else {
1894
- warningMessages.push_back (strprintf ( " unknown new rules are about to activate (versionbit %i) " , bit) );
1899
+ warningMessages.push_back (strWarning );
1895
1900
}
1896
1901
}
1897
1902
}
@@ -1904,16 +1909,12 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
1904
1909
pindex = pindex->pprev ;
1905
1910
}
1906
1911
if (nUpgraded > 0 )
1907
- warningMessages.push_back (strprintf (" %d of last 100 blocks have unexpected version" , nUpgraded));
1912
+ warningMessages.push_back (strprintf (_ ( " %d of last 100 blocks have unexpected version" ) , nUpgraded));
1908
1913
if (nUpgraded > 100 /2 )
1909
1914
{
1910
1915
std::string strWarning = _ (" Warning: Unknown block versions being mined! It's possible unknown rules are in effect" );
1911
1916
// notify GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
1912
- SetMiscWarning (strWarning);
1913
- if (!fWarned ) {
1914
- AlertNotify (strWarning);
1915
- fWarned = true ;
1916
- }
1917
+ DoWarning (strWarning);
1917
1918
}
1918
1919
}
1919
1920
LogPrintf (" %s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utx)" , __func__,
0 commit comments