Skip to content

Commit 580733e

Browse files
authored
Merge pull request #1739 from cyrossignol/beacon
gui: Build onboarding/beacon wizard
2 parents 16db8f8 + 549868e commit 580733e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5165
-818
lines changed

gridcoinresearch.pro

+22
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qu
172172

173173
DEPENDPATH += src src/json src/qt
174174
HEADERS += src/qt/bitcoingui.h \
175+
src/qt/researcher/projecttablemodel.h \
176+
src/qt/researcher/researchermodel.h \
177+
src/qt/researcher/researcherwizard.h \
178+
src/qt/researcher/researcherwizardauthpage.h \
179+
src/qt/researcher/researcherwizardbeaconpage.h \
180+
src/qt/researcher/researcherwizardemailpage.h \
181+
src/qt/researcher/researcherwizardprojectspage.h \
182+
src/qt/researcher/researcherwizardsummarypage.h \
175183
src/qt/transactiontablemodel.h \
176184
src/qt/addresstablemodel.h \
177185
src/qt/optionsdialog.h \
@@ -265,6 +273,14 @@ HEADERS += src/qt/bitcoingui.h \
265273

266274

267275
SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
276+
src/qt/researcher/projecttablemodel.cpp \
277+
src/qt/researcher/researchermodel.cpp \
278+
src/qt/researcher/researcherwizard.cpp \
279+
src/qt/researcher/researcherwizardauthpage.cpp \
280+
src/qt/researcher/researcherwizardbeaconpage.cpp \
281+
src/qt/researcher/researcherwizardemailpage.cpp \
282+
src/qt/researcher/researcherwizardprojectspage.cpp \
283+
src/qt/researcher/researcherwizardsummarypage.cpp \
268284
src/qt/transactiontablemodel.cpp \
269285
src/qt/addresstablemodel.cpp \
270286
src/qt/optionsdialog.cpp \
@@ -354,6 +370,12 @@ RESOURCES += \
354370

355371
FORMS += \
356372
src/qt/forms/coincontroldialog.ui \
373+
src/qt/forms/researcherwizard.ui \
374+
src/qt/forms/researcherwizardauthpage.ui \
375+
src/qt/forms/researcherwizardbeaconpage.ui \
376+
src/qt/forms/researcherwizardemailpage.ui \
377+
src/qt/forms/researcherwizardprojectspage.ui \
378+
src/qt/forms/researcherwizardsummarypage.ui \
357379
src/qt/forms/sendcoinsdialog.ui \
358380
src/qt/forms/addressbookpage.ui \
359381
src/qt/forms/signverifymessagedialog.ui \

src/Makefile.qt.include

+34-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,17 @@ QT_FORMS_UI = \
8181
qt/forms/addressbookpage.ui \
8282
qt/forms/editaddressdialog.ui \
8383
qt/forms/overviewpage.ui \
84+
qt/forms/researcherwizard.ui \
85+
qt/forms/researcherwizardauthpage.ui \
86+
qt/forms/researcherwizardbeaconpage.ui \
87+
qt/forms/researcherwizardemailpage.ui \
88+
qt/forms/researcherwizardprojectspage.ui \
89+
qt/forms/researcherwizardsummarypage.ui \
8490
qt/forms/sendcoinsdialog.ui \
8591
qt/forms/transactiondescdialog.ui \
8692
qt/forms/askpassphrasedialog.ui \
8793
qt/forms/sendcoinsentry.ui
88-
94+
8995
QT_MOC_CPP = \
9096
qt/moc_aboutdialog.cpp \
9197
qt/moc_addressbookpage.cpp \
@@ -124,7 +130,15 @@ QT_MOC_CPP = \
124130
qt/moc_transactiontablemodel.cpp \
125131
qt/moc_transactionview.cpp \
126132
qt/moc_votingdialog.cpp \
127-
qt/moc_walletmodel.cpp
133+
qt/moc_walletmodel.cpp \
134+
qt/researcher/moc_projecttablemodel.cpp \
135+
qt/researcher/moc_researchermodel.cpp \
136+
qt/researcher/moc_researcherwizard.cpp \
137+
qt/researcher/moc_researcherwizardauthpage.cpp \
138+
qt/researcher/moc_researcherwizardbeaconpage.cpp \
139+
qt/researcher/moc_researcherwizardemailpage.cpp \
140+
qt/researcher/moc_researcherwizardprojectspage.cpp \
141+
qt/researcher/moc_researcherwizardsummarypage.cpp
128142

129143
GRIDCOIN_MM = \
130144
qt/macdockiconhandler.mm \
@@ -169,6 +183,14 @@ GRIDCOINRESEARCH_QT_H = \
169183
qt/qtipcserver.h \
170184
qt/qvalidatedlineedit.h \
171185
qt/qvaluecombobox.h \
186+
qt/researcher/projecttablemodel.h \
187+
qt/researcher/researchermodel.h \
188+
qt/researcher/researcherwizard.h \
189+
qt/researcher/researcherwizardauthpage.h \
190+
qt/researcher/researcherwizardbeaconpage.h \
191+
qt/researcher/researcherwizardemailpage.h \
192+
qt/researcher/researcherwizardprojectspage.h \
193+
qt/researcher/researcherwizardsummarypage.h \
172194
qt/rpcconsole.h \
173195
qt/sendcoinsdialog.h \
174196
qt/sendcoinsentry.h \
@@ -212,6 +234,14 @@ GRIDCOINRESEARCH_QT_CPP = \
212234
qt/qtipcserver.cpp \
213235
qt/qvalidatedlineedit.cpp \
214236
qt/qvaluecombobox.cpp \
237+
qt/researcher/projecttablemodel.cpp \
238+
qt/researcher/researchermodel.cpp \
239+
qt/researcher/researcherwizard.cpp \
240+
qt/researcher/researcherwizardauthpage.cpp \
241+
qt/researcher/researcherwizardbeaconpage.cpp \
242+
qt/researcher/researcherwizardemailpage.cpp \
243+
qt/researcher/researcherwizardprojectspage.cpp \
244+
qt/researcher/researcherwizardsummarypage.cpp \
215245
qt/rpcconsole.cpp \
216246
qt/sendcoinsdialog.cpp \
217247
qt/sendcoinsentry.cpp \
@@ -277,6 +307,7 @@ RES_ICONS = \
277307
qt/res/icons/tx_output.svg \
278308
qt/res/icons/tx_por_ss.svg \
279309
qt/res/icons/tx_por.svg \
310+
qt/res/icons/warning.svg \
280311
qt/res/icons/white_and_red_x.svg \
281312
qt/res/icons/www.png \
282313
qt/res/icons/icons_native/overview.svg \
@@ -409,7 +440,7 @@ CLEANFILES += $(CLEAN_QT)
409440
gridcoinresearch_clean: FORCE
410441
rm -f $(CLEAN_QT) $(qt_gridcoinresearch_OBJECTS) qt/gridcoinresearch$(EXEEXT)
411442

412-
gridcoinresearch:
443+
gridcoinresearch:
413444
@echo "$(ZIP_LIBS)"
414445
qt/gridcoinresearch$(EXEEXT)
415446

src/contract/polls.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "neuralnet/contract/contract.h"
1313
#include "neuralnet/contract/message.h"
1414
#include "neuralnet/quorum.h"
15+
#include "neuralnet/researcher.h"
1516
#include "neuralnet/superblock.h"
1617
#include "neuralnet/tally.h"
1718

@@ -174,7 +175,7 @@ std::pair<std::string, std::string> CreateVoteContract(std::string sTitle, std::
174175
const std::string primary_cpid = NN::GetPrimaryCpid();
175176

176177
std::string GRCAddress = DefaultWalletAddress();
177-
double dmag = NN::Quorum::MyMagnitude().Floating();
178+
double dmag = NN::Researcher::Get()->Magnitude().Floating();
178179
double poll_duration = PollDuration(sTitle) * 86400;
179180

180181
// Prevent Double Voting

src/init.cpp

+26-5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ bool static Bind(const CService &addr, bool fError = true) {
194194
return true;
195195
}
196196

197+
static void CreateNewConfigFile()
198+
{
199+
fsbridge::ofstream myConfig;
200+
myConfig.open(GetConfigFile());
201+
202+
myConfig
203+
<< "addnode=addnode-us-central.cycy.me\n"
204+
<< "addnode=ec2-3-81-39-58.compute-1.amazonaws.com\n"
205+
<< "addnode=gridcoin.crypto.fans\n"
206+
<< "addnode=gridcoin.ddns.net\n"
207+
<< "addnode=london.grcnode.co.uk\n"
208+
<< "addnode=nuad.de\n"
209+
<< "addnode=seeds.gridcoin.ifoggz-network.xyz\n"
210+
<< "addnode=www.grcpool.com\n";
211+
}
212+
197213
// Core-specific options shared between UI and daemon
198214
std::string HelpMessage()
199215
{
@@ -493,11 +509,17 @@ bool AppInit2(ThreadHandlerPtr threads)
493509
// ********************************************************* Step 2: parameter interactions
494510

495511

496-
// Gridcoin - Check to see if config is empty?
497512
if (IsConfigFileEmpty())
498513
{
499-
uiInterface.ThreadSafeMessageBox(
500-
"Configuration file empty. \n" + _("Please wait for new user wizard to start..."), "", 0);
514+
try
515+
{
516+
CreateNewConfigFile();
517+
ReadConfigFile(mapArgs, mapMultiArgs);
518+
}
519+
catch (const std::exception& e)
520+
{
521+
LogPrintf("WARNING: failed to create configuration file: %s", e.what());
522+
}
501523
}
502524

503525
//6-10-2014: R Halford: Updating Boost version to 1.5.5 to prevent sync issues; print the boost version to verify:
@@ -1113,8 +1135,7 @@ bool AppInit2(ThreadHandlerPtr threads)
11131135

11141136
NN::ReplayContracts(pindexBest);
11151137

1116-
uiInterface.InitMessage(_("Finding first applicable Research Project..."));
1117-
NN::Researcher::Reload();
1138+
NN::Researcher::Initialize();
11181139

11191140
if (!pwalletMain->IsLocked())
11201141
NN::Researcher::Get()->ImportBeaconKeysFromConfig(pwalletMain);

src/main.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,8 @@ void GetGlobalStatus()
551551
GlobalStatusStruct.netWeight = RoundToString(GetEstimatedNetworkWeight() / 80.0,2);
552552
//todo: use the real weight from miner status (requires scaling)
553553
GlobalStatusStruct.coinWeight = sWeight;
554-
GlobalStatusStruct.magnitude = NN::Quorum::MyMagnitude().ToString();
555-
GlobalStatusStruct.cpid = NN::GetPrimaryCpid();
556554
GlobalStatusStruct.poll = std::move(current_poll);
557555

558-
GlobalStatusStruct.status = msMiningErrors;
559-
560556
unsigned long stk_dropped;
561557

562558
{
@@ -2616,7 +2612,7 @@ class ClaimValidator
26162612
int64_t research_owed = 0;
26172613

26182614
if (const NN::CpidOption cpid = m_claim.m_mining_id.TryCpid()) {
2619-
research_owed = NN::Tally::GetComputer(*cpid, m_block.nTime, m_pindex)->Accrual();
2615+
research_owed = NN::Tally::GetAccrual(*cpid, m_block.nTime, m_pindex);
26202616
}
26212617

26222618
int64_t out_stake_owed;
@@ -2747,6 +2743,7 @@ bool GridcoinConnectBlock(
27472743
}
27482744

27492745
NN::Tally::RecordRewardBlock(pindex);
2746+
NN::Researcher::Refresh();
27502747

27512748
return true;
27522749
}

src/main.h

-3
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,6 @@ struct globalStatusType
219219
std::string difficulty;
220220
std::string netWeight;
221221
std::string coinWeight;
222-
std::string magnitude;
223-
std::string cpid;
224-
std::string status;
225222
std::string poll;
226223
std::string errors;
227224
};

src/miner.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,7 @@ bool CreateGridcoinReward(
10501050
index.nVersion = blocknew.nVersion;
10511051
index.nHeight = pindexPrev->nHeight + 1;
10521052

1053-
const NN::AccrualComputer calc = NN::Tally::GetComputer(*cpid, blocknew.nTime, &index);
1054-
claim.m_research_subsidy = calc->Accrual();
1053+
claim.m_research_subsidy = NN::Tally::GetAccrual(*cpid, blocknew.nTime, &index);
10551054

10561055
// If no pending research subsidy value exists, build an investor claim.
10571056
// This avoids polluting the block index with non-research reward blocks

src/net.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1507,11 +1507,9 @@ void MapPort()
15071507
// The first name is used as information source for addrman.
15081508
// The second name should resolve to a list of seed addresses.
15091509
static const char *strDNSSeed[][2] = {
1510-
{"node.gridcoin.us", "node.gridcoin.us"},
1511-
{"london.grcnode.co.uk", "london.grcnode.co.uk"},
1512-
{"gridcoin.crypto.fans", "gridcoin.crypto.fans"},
1510+
{"addnode-us-central.cycy.me", "addnode-us-central.cycy.me"},
1511+
{"ec2-3-81-39-58.compute-1.amazonaws.com", "ec2-3-81-39-58.compute-1.amazonaws.com"},
15131512
{"node.grcpool.com", "node.grcpool.com"},
1514-
{"nuad.de", "nuad.de"},
15151513
{"seeds.gridcoin.ifoggz-network.xyz", "seeds.gridcoin.ifoggz-network.xyz"},
15161514
{"", ""},
15171515
};

src/neuralnet/accrual/snapshot.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ class SnapshotAccrualComputer : public IAccrualComputer, SnapshotCalculator
234234
// a superblock after contract improvements for more accurate age.
235235
//
236236
if (m_account.IsNew()) {
237-
const int64_t beacon_time = GetBeaconRegistry().Try(m_cpid)->m_timestamp;
237+
if (const BeaconOption beacon = GetBeaconRegistry().Try(m_cpid)) {
238+
const int64_t beacon_time = beacon->m_timestamp;
238239

239-
if (beacon_time <= 0) {
240-
return 0;
240+
if (beacon_time > 0) {
241+
return m_payment_time - beacon_time;
242+
}
241243
}
242244

243-
return m_payment_time - beacon_time;
245+
return 0;
244246
}
245247

246248
return SnapshotCalculator::AccrualAge(m_account);

src/neuralnet/beacon.cpp

+30-22
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,18 @@ BeaconPayload::BeaconPayload()
167167
{
168168
}
169169

170-
BeaconPayload::BeaconPayload(const Cpid cpid, Beacon beacon)
171-
: m_cpid(cpid)
170+
BeaconPayload::BeaconPayload(const uint32_t version, const Cpid cpid, Beacon beacon)
171+
: m_version(version)
172+
, m_cpid(cpid)
172173
, m_beacon(std::move(beacon))
173174
{
174175
}
175176

177+
BeaconPayload::BeaconPayload(const Cpid cpid, Beacon beacon)
178+
: BeaconPayload(CURRENT_VERSION, cpid, std::move(beacon))
179+
{
180+
}
181+
176182
BeaconPayload BeaconPayload::Parse(const std::string& key, const std::string& value)
177183
{
178184
const CpidOption cpid = MiningId::Parse(key).TryCpid();
@@ -181,13 +187,8 @@ BeaconPayload BeaconPayload::Parse(const std::string& key, const std::string& va
181187
return BeaconPayload();
182188
}
183189

184-
Beacon beacon = Beacon::Parse(value);
185-
186-
if (!beacon.WellFormed()) {
187-
return BeaconPayload();
188-
}
189-
190-
return BeaconPayload(*cpid, std::move(beacon));
190+
// Legacy beacon payloads always parse to version 1:
191+
return BeaconPayload(1, *cpid, Beacon::Parse(value));
191192
}
192193

193194
bool BeaconPayload::Sign(CKey& private_key)
@@ -262,6 +263,26 @@ BeaconOption BeaconRegistry::TryActive(const Cpid& cpid, const int64_t now) cons
262263
return nullptr;
263264
}
264265

266+
std::vector<const PendingBeacon*> BeaconRegistry::FindPending(const Cpid cpid) const
267+
{
268+
// TODO: consider adding a lookup table for pending beacons keyed by CPID.
269+
// Since the protocol just needs to look up pending beacons by public key,
270+
// we just do a search here. Informational RPCs or local beacon management
271+
// only need to call this occasionally.
272+
273+
std::vector<const PendingBeacon*> found;
274+
275+
for (const auto& pending_beacon_pair : m_pending) {
276+
const PendingBeacon& beacon = pending_beacon_pair.second;
277+
278+
if (beacon.m_cpid == cpid) {
279+
found.emplace_back(&beacon);
280+
}
281+
}
282+
283+
return found;
284+
}
285+
265286
bool BeaconRegistry::ContainsActive(const Cpid& cpid, const int64_t now) const
266287
{
267288
if (const BeaconOption beacon = Try(cpid)) {
@@ -276,19 +297,6 @@ bool BeaconRegistry::ContainsActive(const Cpid& cpid) const
276297
return ContainsActive(cpid, GetAdjustedTime());
277298
}
278299

279-
std::vector<CKeyID> BeaconRegistry::FindPendingKeys(const Cpid& cpid) const
280-
{
281-
std::vector<CKeyID> found;
282-
283-
for (const auto& beacon_pair : m_pending) {
284-
if (beacon_pair.second.m_cpid == cpid) {
285-
found.emplace_back(beacon_pair.first);
286-
}
287-
}
288-
289-
return found;
290-
}
291-
292300
void BeaconRegistry::Add(Contract contract)
293301
{
294302
BeaconPayload payload = contract.CopyPayloadAs<BeaconPayload>();

0 commit comments

Comments
 (0)