Skip to content

Commit d73d6f5

Browse files
authored
Merge pull request #1646 from jamescowens/beacon_status_button
Implement beacon status icon/button
2 parents f9d73b2 + dca0a8d commit d73d6f5

38 files changed

+1565
-95
lines changed

src/Makefile.qt.include

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,12 @@ GRIDCOINRESEARCH_QT_CPP = \
229229
qt/winshutdownmonitor.cpp
230230

231231
RES_ICONS = \
232+
qt/res/icons/2tx_cpumined.png \
232233
qt/res/icons/add.png \
233-
qt/res/icons/gridcoin.ico \
234+
qt/res/icons/beacon_green.svg \
235+
qt/res/icons/beacon_grey.svg \
236+
qt/res/icons/beacon_red.svg \
237+
qt/res/icons/beacon_yellow.svg \
234238
qt/res/icons/bitcoin_testnet.ico \
235239
qt/res/icons/block.png \
236240
qt/res/icons/chat.png \
@@ -240,11 +244,11 @@ RES_ICONS = \
240244
qt/res/icons/clock4.png \
241245
qt/res/icons/clock5.png \
242246
qt/res/icons/configure.png \
243-
qt/res/icons/connect0_16.png \
244-
qt/res/icons/connect1_16.png \
245-
qt/res/icons/connect2_16.png \
246-
qt/res/icons/connect3_16.png \
247-
qt/res/icons/connect4_16.png \
247+
qt/res/icons/connect0.svg \
248+
qt/res/icons/connect1.svg \
249+
qt/res/icons/connect2.svg \
250+
qt/res/icons/connect3.svg \
251+
qt/res/icons/connect4.svg \
248252
qt/res/icons/debugwindow.png \
249253
qt/res/icons/edit.png \
250254
qt/res/icons/editcopy.png \
@@ -253,33 +257,36 @@ RES_ICONS = \
253257
qt/res/icons/export.png \
254258
qt/res/icons/filesave.png \
255259
qt/res/icons/gold_cpumined.gif \
260+
qt/res/icons/gray_scraper.svg \
261+
qt/res/icons/green_check.svg \
262+
qt/res/icons/green_scraper.svg \
263+
qt/res/icons/gridcoin.ico \
256264
qt/res/icons/key.png \
265+
qt/res/icons/notsynced.svg \
257266
qt/res/icons/overview2.png \
258267
qt/res/icons/qrcode.png \
259268
qt/res/icons/quit.png \
260269
qt/res/icons/remove.png \
261270
qt/res/icons/rsz_chat.png \
262-
qt/res/icons/staking_off.png \
263-
qt/res/icons/staking_on.png \
271+
qt/res/icons/staking_off.svg \
272+
qt/res/icons/staking_on.svg \
264273
qt/res/icons/statistics.png \
265-
qt/res/icons/notsynced.png \
266-
qt/res/icons/synced.png \
267274
qt/res/icons/toolbar.png \
275+
qt/res/icons/transaction_conflicted.png \
268276
qt/res/icons/transaction0.png \
269277
qt/res/icons/transaction2.png \
270-
qt/res/icons/transaction_conflicted.png \
271-
qt/res/icons/tx2.png \
272-
qt/res/icons/2tx_cpumined.png \
273-
qt/res/icons/tx_minedoie_WOEI3ooIzGHI.png \
274-
qt/res/icons/www.png \
275-
qt/res/icons/wwww.png \
276278
qt/res/icons/tx_inout.svg \
277279
qt/res/icons/tx_input.svg \
280+
qt/res/icons/tx_mined_ss.svg \
278281
qt/res/icons/tx_mined.svg \
282+
qt/res/icons/tx_minedoie_WOEI3ooIzGHI.png \
279283
qt/res/icons/tx_output.svg \
280-
qt/res/icons/tx_por.svg \
281-
qt/res/icons/tx_mined_ss.svg \
282284
qt/res/icons/tx_por_ss.svg \
285+
qt/res/icons/tx_por.svg \
286+
qt/res/icons/tx2.png \
287+
qt/res/icons/white_and_red_x.svg \
288+
qt/res/icons/www.png \
289+
qt/res/icons/wwww.png \
283290
qt/res/icons/icons_native/overview.svg \
284291
qt/res/icons/icons_light/overview.svg \
285292
qt/res/icons/icons_dark/overview.svg \

src/beacon.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "appcache.h"
99
#include "contract/contract.h"
1010
#include "key.h"
11+
#include "neuralnet/researcher.h"
12+
#include "neuralnet/tally.h"
1113

1214
std::string RetrieveBeaconValueWithMaxAge(const std::string& cpid, int64_t iMaxSeconds);
1315
std::string ExtractXML(const std::string& XMLdata, const std::string& key, const std::string& key_end);
@@ -316,3 +318,25 @@ BeaconConsensus GetConsensusBeaconList()
316318

317319
return Consensus;
318320
}
321+
322+
// -------------------------- Both In and Out
323+
BeaconStatus GetBeaconStatus(std::string& sCPID)
324+
{
325+
BeaconStatus beacon_status;
326+
327+
LOCK(cs_main);
328+
329+
if (sCPID.empty())
330+
{
331+
sCPID = NN::GetPrimaryCpid();
332+
}
333+
334+
beacon_status.sPubKey = GetBeaconPublicKey(sCPID, false);
335+
beacon_status.iBeaconTimestamp = BeaconTimeStamp(sCPID);
336+
beacon_status.timestamp = TimestampToHRDate(beacon_status.iBeaconTimestamp);
337+
beacon_status.hasBeacon = HasActiveBeacon(sCPID);
338+
beacon_status.dPriorSBMagnitude = NN::Tally::GetMagnitude(NN::MiningId::Parse(sCPID));
339+
beacon_status.is_mine = (sCPID == NN::GetPrimaryCpid());
340+
341+
return beacon_status;
342+
}

src/beacon.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ struct BeaconConsensus
2525
BeaconMap mBeaconMap;
2626
};
2727

28+
//Note this should be replaced when we redo the beacon structures...
29+
struct BeaconStatus
30+
{
31+
std::string sPubKey;
32+
int64_t iBeaconTimestamp;
33+
std::string timestamp;
34+
bool hasBeacon;
35+
double dPriorSBMagnitude;
36+
bool is_mine;
37+
};
38+
2839
//!
2940
//! \brief Generate beacon key pair.
3041
//!
@@ -100,3 +111,10 @@ bool ImportBeaconKeysFromConfig(const std::string& cpid, CWallet* wallet);
100111
//! \return A list of active beacons.
101112
//!
102113
BeaconConsensus GetConsensusBeaconList();
114+
115+
//!
116+
//! \brief Get beacon status for a specified CPID.
117+
//!
118+
//! \return Beacon status structure for specific CPID.
119+
//!
120+
BeaconStatus GetBeaconStatus(std::string& sCPID);

src/neuralnet/researcher.cpp

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,6 @@ std::string LowerUnderscore(std::string data)
4444
return data;
4545
}
4646

47-
//!
48-
//! \brief Determine whether the wallet must run in investor mode before trying
49-
//! to load BOINC CPIDs.
50-
//!
51-
//! \return \c true if the user explicitly configured investor mode or failed
52-
//! to input a valid email address.
53-
//!
54-
bool ConfiguredForInvestorMode()
55-
{
56-
if (GetBoolArg("-investor", false)) {
57-
LogPrintf("Investor mode configured. Skipping CPID import.");
58-
return true;
59-
}
60-
61-
if (Researcher::Email().empty()) {
62-
LogPrintf(
63-
"WARNING: Please set 'email=<your BOINC account email>' in "
64-
"gridcoinresearch.conf. Continuing in investor mode.");
65-
66-
return true;
67-
}
68-
69-
return false;
70-
}
71-
7247
//!
7348
//! \brief Fetch the contents of BOINC's client_state.xml file from disk.
7449
//!
@@ -507,14 +482,32 @@ std::string Researcher::Email()
507482
return email;
508483
}
509484

485+
bool Researcher::ConfiguredForInvestorMode(bool log)
486+
{
487+
if (GetBoolArg("-investor", false)) {
488+
if (log) LogPrintf("Investor mode configured. Skipping CPID import.");
489+
return true;
490+
}
491+
492+
if (Researcher::Email().empty()) {
493+
if (log) LogPrintf(
494+
"WARNING: Please set 'email=<your BOINC account email>' in "
495+
"gridcoinresearch.conf. Continuing in investor mode.");
496+
497+
return true;
498+
}
499+
500+
return false;
501+
}
502+
510503
ResearcherPtr Researcher::Get()
511504
{
512505
return std::atomic_load(&researcher);
513506
}
514507

515508
void Researcher::Reload()
516509
{
517-
if (ConfiguredForInvestorMode()) {
510+
if (ConfiguredForInvestorMode(true)) {
518511
StoreResearcher(Researcher()); // Investor
519512
return;
520513
}

src/neuralnet/researcher.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ class Researcher
220220
//!
221221
static std::string Email();
222222

223+
//!
224+
//! \brief Determine whether the wallet must run in investor mode before trying
225+
//! to load BOINC CPIDs.
226+
//!
227+
//! \return \c true if the user explicitly configured investor mode or failed
228+
//! to input a valid email address.
229+
//!
230+
static bool ConfiguredForInvestorMode(bool log = false);
231+
223232
//!
224233
//! \brief Get the current global researcher context.
225234
//!

src/qt/bitcoin.qrc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<RCC>
22
<qresource prefix="/icons">
33
<file alias="quit">res/icons/quit.png</file>
4-
<file alias="connect_0">res/icons/connect0_16.png</file>
5-
<file alias="connect_1">res/icons/connect1_16.png</file>
6-
<file alias="connect_2">res/icons/connect2_16.png</file>
7-
<file alias="connect_3">res/icons/connect3_16.png</file>
8-
<file alias="connect_4">res/icons/connect4_16.png</file>
94
<file alias="transaction_0">res/icons/transaction0.png</file>
105
<file alias="transaction_confirmed">res/icons/transaction2.png</file>
116
<file alias="transaction_conflicted">res/icons/transaction_conflicted.png</file>
@@ -20,14 +15,11 @@
2015
<file alias="add">res/icons/add.png</file>
2116
<file alias="edit">res/icons/edit.png</file>
2217
<file alias="export">res/icons/export.png</file>
23-
<file alias="synced">res/icons/synced.png</file>
2418
<file alias="remove">res/icons/remove.png</file>
2519
<file alias="key">res/icons/key.png</file>
2620
<file alias="filesave">res/icons/filesave.png</file>
2721
<file alias="qrcode">res/icons/qrcode.png</file>
2822
<file alias="debugwindow">res/icons/debugwindow.png</file>
29-
<file alias="staking_off">res/icons/staking_off.png</file>
30-
<file alias="staking_on">res/icons/staking_on.png</file>
3123
<file alias="block">res/icons/block.png</file>
3224
<file alias="ex">res/icons/ex.png</file>
3325
<file alias="www">res/icons/www.png</file>
@@ -63,7 +55,22 @@
6355
<file alias="tx_mined_ss">res/icons/tx_mined_ss.svg</file>
6456
<file alias="tx_cpumined">res/icons/tx_por.svg</file>
6557
<file alias="tx_cpumined_ss">res/icons/tx_por_ss.svg</file>
66-
<file alias="notsynced">res/icons/notsynced.png</file>
58+
<file alias="beacon_green">res/icons/beacon_green.svg</file>
59+
<file alias="beacon_grey">res/icons/beacon_grey.svg</file>
60+
<file alias="beacon_red">res/icons/beacon_red.svg</file>
61+
<file alias="beacon_yellow">res/icons/beacon_yellow.svg</file>
62+
<file alias="staking_off">res/icons/staking_off.svg</file>
63+
<file alias="staking_on">res/icons/staking_on.svg</file>
64+
<file alias="gray_scraper">res/icons/gray_scraper.svg</file>
65+
<file alias="green_scraper">res/icons/green_scraper.svg</file>
66+
<file alias="connect_0">res/icons/connect0.svg</file>
67+
<file alias="connect_1">res/icons/connect1.svg</file>
68+
<file alias="connect_2">res/icons/connect2.svg</file>
69+
<file alias="connect_3">res/icons/connect3.svg</file>
70+
<file alias="connect_4">res/icons/connect4.svg</file>
71+
<file alias="notsynced">res/icons/notsynced.svg</file>
72+
<file alias="synced">res/icons/green_check.svg</file>
73+
<file alias="white_and_red_x">res/icons/white_and_red_x.svg</file>
6774
</qresource>
6875
<qresource prefix="/images">
6976
<file alias="splash">res/images/splash3.png</file>

0 commit comments

Comments
 (0)