26
26
#include " gridcoin/staking/kernel.h"
27
27
#include " gridcoin/staking/reward.h"
28
28
#include " gridcoin/staking/spam.h"
29
- #include " gridcoin/staking/status.h"
30
29
#include " gridcoin/superblock.h"
31
30
#include " gridcoin/support/xml.h"
32
31
#include " gridcoin/tally.h"
@@ -128,9 +127,6 @@ int nGrandfather = 1034700;
128
127
129
128
int64_t nGenesisSupply = 340569880 ;
130
129
131
- // Stats for Main Screen:
132
- GlobalStatus g_GlobalStatus;
133
-
134
130
bool fColdBoot = true ;
135
131
bool fEnforceCanonical = true ;
136
132
bool fUseFastIndex = false ;
@@ -153,108 +149,6 @@ arith_uint256 GetChainTrust(const CBlockIndex* pindex)
153
149
return g_chain_trust.GetTrust (pindex);
154
150
}
155
151
156
- void GlobalStatus::SetGlobalStatus (bool force)
157
- {
158
- // Only update if the previous update is >= 4 seconds old or force is specified to avoid
159
- // unnecessary calculations.
160
- if (force || GetAdjustedTime () - update_time >= 4 )
161
- {
162
- // These are atomics and do not need a lock on cs_errors_lock to update. But the global variable
163
- // and functions called need a lock on cs_main.
164
- {
165
- LOCK (cs_main);
166
-
167
- blocks = nBestHeight;
168
- netWeight = GRC::GetEstimatedNetworkWeight () / 80.0 ;
169
- difficulty = GRC::GetCurrentDifficulty ();
170
- etts = GRC::GetEstimatedTimetoStake ();
171
- }
172
-
173
- update_time = GetAdjustedTime ();
174
-
175
- try
176
- {
177
- unsigned long stk_dropped;
178
-
179
- {
180
- staking = g_miner_status.StakingActive ();
181
- coinWeight = g_miner_status.GetSearchReport ().CoinWeight ();
182
- able_to_stake = g_miner_status.StakingEnabled ();
183
- ReasonNotStaking = g_miner_status.FormatErrors ();
184
-
185
- errors.clear ();
186
-
187
- if (difficulty < 0.1 )
188
- {
189
- errors += _ (" Low difficulty!; " );
190
- }
191
-
192
- if (!ReasonNotStaking.empty ())
193
- {
194
- errors += _ (" Miner: " ) + ReasonNotStaking;
195
- }
196
-
197
- stk_dropped = g_miner_status.GetSearchReport ().KernelsRejected ();
198
- }
199
-
200
- if (stk_dropped)
201
- {
202
- errors += " Rejected " + ToString (stk_dropped) + " stakes;" ;
203
- }
204
-
205
- return ;
206
- }
207
- catch (std::exception & e)
208
- {
209
- errors = _ (" Error obtaining status." );
210
-
211
- LogPrintf (" Error obtaining status" );
212
- return ;
213
- }
214
- }
215
- }
216
-
217
- const GlobalStatus::globalStatusType GlobalStatus::GetGlobalStatus ()
218
- {
219
- globalStatusType globalStatus;
220
-
221
- globalStatus.update_time = update_time;
222
- globalStatus.blocks = blocks;
223
- globalStatus.difficulty = difficulty;
224
- globalStatus.netWeight = netWeight;
225
- globalStatus.coinWeight = coinWeight;
226
- globalStatus.etts = etts;
227
-
228
- globalStatus.able_to_stake = able_to_stake;
229
- globalStatus.staking = staking;
230
-
231
- LOCK (cs_errors_lock);
232
-
233
- globalStatus.ReasonNotStaking = ReasonNotStaking;
234
- globalStatus.errors = errors;
235
-
236
- return globalStatus;
237
- }
238
-
239
- const GlobalStatus::globalStatusStringType GlobalStatus::GetGlobalStatusStrings ()
240
- {
241
- const globalStatusType& globalStatus = GetGlobalStatus ();
242
-
243
- globalStatusStringType globalStatusStrings;
244
-
245
- if (update_time > 0 )
246
- {
247
- globalStatusStrings.blocks = ToString (globalStatus.blocks );
248
- globalStatusStrings.difficulty = RoundToString (globalStatus.difficulty , 3 );
249
- globalStatusStrings.netWeight = RoundToString (globalStatus.netWeight , 2 );
250
- globalStatusStrings.coinWeight = RoundToString (globalStatus.coinWeight , 2 );
251
-
252
- globalStatusStrings.errors = globalStatus.errors ;
253
- }
254
-
255
- return globalStatusStrings;
256
- }
257
-
258
152
void RegisterWallet (CWallet* pwalletIn)
259
153
{
260
154
{
@@ -2037,6 +1931,8 @@ bool SetBestChain(CTxDB& txdb, CBlock &blockNew, CBlockIndex* pindexNew)
2037
1931
boost::thread t (runCommand, strCmd); // thread runs free
2038
1932
}
2039
1933
1934
+ uiInterface.NotifyBlocksChanged (fIsInitialDownload , pindexNew->nHeight , pindexNew->GetBlockTime ());
1935
+
2040
1936
return GridcoinServices ();
2041
1937
}
2042
1938
@@ -2105,7 +2001,6 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const u
2105
2001
hashPrevBestCoinBase = vtx[0 ].GetHash ();
2106
2002
}
2107
2003
2108
- uiInterface.NotifyBlocksChanged ();
2109
2004
return true ;
2110
2005
}
2111
2006
@@ -2434,19 +2329,6 @@ arith_uint256 CBlockIndex::GetBlockTrust() const
2434
2329
2435
2330
bool GridcoinServices ()
2436
2331
{
2437
- // This is only necessary if the GUI is running. It is also really only necessary during
2438
- // rapid block influx during sync. SetGlobalStatus runs from the ClientModel timer with the force
2439
- // parameter set as well. Not sure any of this is necessary, since the overview page updateglobalstatus
2440
- // and UpdateBoincUtilization run a "hard" GlobalStatus update anyway, on a MODEL_UPDATE_DELAY timer.
2441
- if (fQtActive && (nBestHeight % 125 ) == 0 && nBestHeight > 0 )
2442
- {
2443
- // Do a "soft" GlobalStatus update. In addition to the 125 block ladder above, the "soft" update
2444
- // will only actually update if more than 4 seconds has elapsed since the last call.
2445
- g_GlobalStatus.SetGlobalStatus ();
2446
- // Emit the NotifyBlocksChanged signal. Note that this signal is not actually hooked up right now.
2447
- uiInterface.NotifyBlocksChanged ();
2448
- }
2449
-
2450
2332
// Block version 9 tally transition:
2451
2333
//
2452
2334
// This block controls the switch to a new tallying system introduced with
@@ -3035,33 +2917,20 @@ string GetWarnings(string strFor)
3035
2917
}
3036
2918
}
3037
2919
3038
- const GlobalStatus::globalStatusType status = g_GlobalStatus.GetGlobalStatus ();
3039
-
3040
- if (!strStatusBar.empty () && !status.errors .empty ()) {
3041
- strStatusBar += " ; " ;
3042
- }
3043
-
3044
- strStatusBar += status.errors ;
3045
-
3046
2920
if (strFor == " statusbar" )
2921
+ {
3047
2922
return strStatusBar;
2923
+ }
2924
+
3048
2925
assert (!" GetWarnings() : invalid parameter" );
3049
2926
return " error" ;
3050
2927
}
3051
2928
3052
-
3053
-
3054
-
3055
-
3056
-
3057
-
3058
-
3059
2929
// ////////////////////////////////////////////////////////////////////////////
3060
2930
//
3061
2931
// Messages
3062
2932
//
3063
2933
3064
-
3065
2934
bool static AlreadyHave (CTxDB& txdb, const CInv& inv)
3066
2935
{
3067
2936
switch (inv.type )
0 commit comments