1111#include " util.hpp"
1212#include " web_client.hpp"
1313
14+ const std::string Setup::LODA_SUBMIT_CPU_HOURS (" LODA_SUBMIT_CPU_HOURS" );
15+
16+ // TODO: use a singlton of Setup
1417std::string Setup::LODA_HOME;
1518std::string Setup::OEIS_HOME;
1619std::string Setup::PROGRAMS_HOME;
@@ -304,23 +307,29 @@ void Setup::runWizard() {
304307 if (!checkMiningMode ()) {
305308 return ;
306309 }
307- if (!checkSubmittedBy ()) {
308- return ;
310+ if (MINING_MODE == MINING_MODE_CLIENT) {
311+ if (!checkSubmittedBy ()) {
312+ return ;
313+ }
314+ if (!checkUsageStats ()) {
315+ return ;
316+ }
309317 }
310-
311318 std::cout << " Configure advanced settings? (y/N) " ;
312319 std::getline (std::cin, line);
313320 std::cout << std::endl;
314- if (line == " y" || line == " Y" ) {
321+ if (line == " y" || line == " Y" || line == " yes " ) {
315322 if (!checkMaxInstances ()) {
316323 return ;
317324 }
318325 if (!checkMaxMemory ()) {
319326 return ;
320327 }
321- if (!checkUpdateInterval ()) {
322- return ;
323- }
328+ // since we get the oeis data from the API server, we don't need to
329+ // configure this anymore
330+ // if (!checkUpdateInterval()) {
331+ // return;
332+ // }
324333#ifdef STD_FILESYSTEM
325334 if (getMiningMode () == MINING_MODE_CLIENT && !checkMaxLocalProgramAge ()) {
326335 return ;
@@ -543,7 +552,7 @@ bool Setup::checkMiningMode() {
543552 return false ;
544553 }
545554 SETUP[" LODA_MINING_MODE" ] = convertMiningModeToStr (mode);
546- MINING_MODE = UNDEFINED_INT; // reset cached value
555+ MINING_MODE = mode;
547556 std::cout << std::endl;
548557 return true ;
549558}
@@ -610,9 +619,9 @@ bool Setup::checkSubmittedBy() {
610619 << std::endl
611620 << " at https://loda-lang.org and the programs repository at"
612621 << std::endl
613- << " https://github.com/loda-lang/loda-programs. If you like, "
622+ << " https://github.com/loda-lang/loda-programs." << std::endl
614623 << std::endl
615- << " enter your name below , or \" none\" to not include it:"
624+ << " Enter your name, or \" none\" to not include it in programs :"
616625 << std::endl;
617626 std::cout << " [" << submitted_by << " ] " ;
618627 std::getline (std::cin, submitted_by);
@@ -627,11 +636,46 @@ bool Setup::checkSubmittedBy() {
627636 return true ;
628637}
629638
639+ bool Setup::checkUsageStats () {
640+ std::cout << " To estimate the required server capacity, the LODA miner"
641+ << std::endl
642+ << " can send basic, anonymous usage statistics. Specifically,"
643+ << std::endl
644+ << " a running miner instance would send the value 1 to the"
645+ << std::endl
646+ << " API server once per hour. This data is used to determine"
647+ << std::endl
648+ << " the total number of active miners. There are no IDs or other"
649+ << std::endl
650+ << " data sent to the server. You can still mine without it."
651+ << std::endl
652+ << std::endl
653+ << " Do you want to send this basic usage statisics? " ;
654+ bool flag = getSetupFlag (LODA_SUBMIT_CPU_HOURS, false );
655+ if (flag) {
656+ std::cout << " (Y/n) " ;
657+ } else {
658+ std::cout << " (y/N) " ;
659+ }
660+ std::string line;
661+ std::getline (std::cin, line);
662+ std::cout << std::endl;
663+ if (!line.empty ()) {
664+ if (line == " y" || line == " Y" || line == " yes" ) {
665+ SETUP[LODA_SUBMIT_CPU_HOURS] = " yes" ;
666+ } else {
667+ SETUP[LODA_SUBMIT_CPU_HOURS] = " no" ;
668+ }
669+ }
670+ return true ;
671+ }
672+
630673bool Setup::checkMaxMemory () {
631674 std::string line;
632675 std::cout << " Enter the maximum memory usage per miner instance in MB."
633676 << std::endl
634- << " The default value is " << DEFAULT_MAX_PHYSICAL_MEMORY << " MB."
677+ << " The recommended range is " << DEFAULT_MAX_PHYSICAL_MEMORY
678+ << " - " << (DEFAULT_MAX_PHYSICAL_MEMORY * 2 ) << " MB."
635679 << std::endl;
636680 int64_t max_memory = getMaxMemory () / (1024 * 1024 );
637681 std::cout << " [" << max_memory << " ] " ;
0 commit comments