15
15
#include < numeric>
16
16
#include < fstream>
17
17
18
- extern std::unique_ptr<Upgrade> g_UpdateChecker;
19
-
20
18
namespace NN { std::string GetPrimaryCpid (); }
21
19
22
20
DiagnosticsDialog::DiagnosticsDialog (QWidget *parent) :
@@ -82,7 +80,7 @@ void DiagnosticsDialog::UpdateOverallDiagnosticResult(DiagnosticResult diagnosti
82
80
diagnostic_result_status = pending;
83
81
}
84
82
85
- diagnostic_result = (DiagnosticResult) std::max (( int ) diagnostic_result_in, ( int ) diagnostic_result);
83
+ diagnostic_result = (DiagnosticResult) std::max< int >( diagnostic_result_in, diagnostic_result);
86
84
87
85
// If diagnostic_result_status is still set to completed, then at least all tests
88
86
// are registered. Walk through the map of tests one by one and check the status.
@@ -134,7 +132,7 @@ void DiagnosticsDialog::DisplayOverallDiagnosticResult()
134
132
135
133
case passed:
136
134
ui->overallResultResultLabel ->setText (tr (" Passed" ));
137
- ui->overallResultResultLabel ->setStyleSheet (" color:black ;background-color:green" );
135
+ ui->overallResultResultLabel ->setStyleSheet (" color:white ;background-color:green" );
138
136
break ;
139
137
140
138
case warning:
@@ -144,7 +142,7 @@ void DiagnosticsDialog::DisplayOverallDiagnosticResult()
144
142
145
143
case failed:
146
144
ui->overallResultResultLabel ->setText (tr (" Failed" ));
147
- ui->overallResultResultLabel ->setStyleSheet (" color:black ;background-color:red" );
145
+ ui->overallResultResultLabel ->setStyleSheet (" color:white ;background-color:red" );
148
146
}
149
147
}
150
148
@@ -300,7 +298,7 @@ void DiagnosticsDialog::on_testButton_clicked()
300
298
301
299
if (GetNumberOfTestsPending ())
302
300
{
303
- LogPrintf (" INFO: on_testButton_clicked: Tests still in progress from a prior run: %u" , GetNumberOfTestsPending ());
301
+ LogPrintf (" INFO: DiagnosticsDialog:: on_testButton_clicked: Tests still in progress from a prior run: %u" , GetNumberOfTestsPending ());
304
302
this ->repaint ();
305
303
return ;
306
304
}
@@ -342,14 +340,14 @@ void DiagnosticsDialog::on_testButton_clicked()
342
340
if (VerifyBoincPath ())
343
341
{
344
342
ui->boincPathResultLabel ->setText (tr (" Passed" ));
345
- ui->boincPathResultLabel ->setStyleSheet (" color:black ;background-color:green" );
343
+ ui->boincPathResultLabel ->setStyleSheet (" color:white ;background-color:green" );
346
344
UpdateTestStatus (" boincPath" , completed);
347
345
UpdateOverallDiagnosticResult (passed);
348
346
}
349
347
else
350
348
{
351
349
ui->boincPathResultLabel ->setText (tr (" Failed" ));
352
- ui->boincPathResultLabel ->setStyleSheet (" color:black ;background-color:red" );
350
+ ui->boincPathResultLabel ->setStyleSheet (" color:white ;background-color:red" );
353
351
UpdateTestStatus (" boincPath" , completed);
354
352
UpdateOverallDiagnosticResult (failed);
355
353
}
@@ -363,14 +361,14 @@ void DiagnosticsDialog::on_testButton_clicked()
363
361
if (VerifyIsCPIDValid ())
364
362
{
365
363
ui->verifyCPIDValidResultLabel ->setText (tr (" Passed" ));
366
- ui->verifyCPIDValidResultLabel ->setStyleSheet (" color:black ;background-color:green" );
364
+ ui->verifyCPIDValidResultLabel ->setStyleSheet (" color:white ;background-color:green" );
367
365
UpdateTestStatus (" verifyCPIDValid" , completed);
368
366
UpdateOverallDiagnosticResult (passed);
369
367
}
370
368
else
371
369
{
372
370
ui->verifyCPIDValidResultLabel ->setText (tr (" Failed: BOINC CPID does not match CPID" ));
373
- ui->verifyCPIDValidResultLabel ->setStyleSheet (" color:black ;background-color:red" );
371
+ ui->verifyCPIDValidResultLabel ->setStyleSheet (" color:white ;background-color:red" );
374
372
UpdateTestStatus (" verifyCPIDValid" , completed);
375
373
UpdateOverallDiagnosticResult (failed);
376
374
}
@@ -384,15 +382,15 @@ void DiagnosticsDialog::on_testButton_clicked()
384
382
if (VerifyCPIDHasRAC ())
385
383
{
386
384
ui->verifyCPIDHasRACResultLabel ->setText (tr (" Passed" ));
387
- ui->verifyCPIDHasRACResultLabel ->setStyleSheet (" color:black ;background-color:green" );
385
+ ui->verifyCPIDHasRACResultLabel ->setStyleSheet (" color:white ;background-color:green" );
388
386
UpdateTestStatus (" verifyCPIDHasRAC" , completed);
389
387
UpdateOverallDiagnosticResult (passed);
390
388
391
389
}
392
390
else
393
391
{
394
392
ui->verifyCPIDHasRACResultLabel ->setText (tr (" Failed" ));
395
- ui->verifyCPIDHasRACResultLabel ->setStyleSheet (" color:black ;background-color:red" );
393
+ ui->verifyCPIDHasRACResultLabel ->setStyleSheet (" color:white ;background-color:red" );
396
394
UpdateTestStatus (" verifyCPIDHasRAC" , completed);
397
395
UpdateOverallDiagnosticResult (failed);
398
396
}
@@ -406,14 +404,14 @@ void DiagnosticsDialog::on_testButton_clicked()
406
404
if (VerifyCPIDIsInNeuralNetwork ())
407
405
{
408
406
ui->verifyCPIDIsInNNResultLabel ->setText (tr (" Passed" ));
409
- ui->verifyCPIDIsInNNResultLabel ->setStyleSheet (" color:black ;background-color:green" );
407
+ ui->verifyCPIDIsInNNResultLabel ->setStyleSheet (" color:white ;background-color:green" );
410
408
UpdateTestStatus (" verifyCPIDIsInNN" , completed);
411
409
UpdateOverallDiagnosticResult (passed);
412
410
}
413
411
else
414
412
{
415
413
ui->verifyCPIDIsInNNResultLabel ->setText (tr (" Failed" ));
416
- ui->verifyCPIDIsInNNResultLabel ->setStyleSheet (" color:black ;background-color:red" );
414
+ ui->verifyCPIDIsInNNResultLabel ->setStyleSheet (" color:white ;background-color:red" );
417
415
UpdateTestStatus (" verifyCPIDIsInNN" , completed);
418
416
UpdateOverallDiagnosticResult (failed);
419
417
}
@@ -429,15 +427,15 @@ void DiagnosticsDialog::on_testButton_clicked()
429
427
if (VerifyWalletIsSynced ())
430
428
{
431
429
ui->verifyWalletIsSyncedResultLabel ->setText (tr (" Passed" ));
432
- ui->verifyWalletIsSyncedResultLabel ->setStyleSheet (" color:black ;background-color:green" );
430
+ ui->verifyWalletIsSyncedResultLabel ->setStyleSheet (" color:white ;background-color:green" );
433
431
UpdateTestStatus (" verifyWalletIsSynced" , completed);
434
432
UpdateOverallDiagnosticResult (passed);
435
433
}
436
434
437
435
else
438
436
{
439
437
ui->verifyWalletIsSyncedResultLabel ->setText (tr (" Failed" ));
440
- ui->verifyWalletIsSyncedResultLabel ->setStyleSheet (" color:black ;background-color:red" );
438
+ ui->verifyWalletIsSyncedResultLabel ->setStyleSheet (" color:white ;background-color:red" );
441
439
UpdateTestStatus (" verifyWalletIsSynced" , completed);
442
440
UpdateOverallDiagnosticResult (failed);
443
441
}
@@ -468,14 +466,14 @@ void DiagnosticsDialog::on_testButton_clicked()
468
466
else if (seed_node_connections >= 3 )
469
467
{
470
468
ui->verifySeedNodesResultLabel ->setText (tr (" Passed: Count = %1" ).arg (QString::number (seed_node_connections)));
471
- ui->verifySeedNodesResultLabel ->setStyleSheet (" color:black ;background-color:green" );
469
+ ui->verifySeedNodesResultLabel ->setStyleSheet (" color:white ;background-color:green" );
472
470
UpdateTestStatus (" verifySeedNodes" , completed);
473
471
UpdateOverallDiagnosticResult (passed);
474
472
}
475
473
else
476
474
{
477
475
ui->verifySeedNodesResultLabel ->setText (tr (" Failed: Count = %1" ).arg (QString::number (seed_node_connections)));
478
- ui->verifySeedNodesResultLabel ->setStyleSheet (" color:black ;background-color:red" );
476
+ ui->verifySeedNodesResultLabel ->setStyleSheet (" color:white ;background-color:red" );
479
477
UpdateTestStatus (" verifySeedNodes" , completed);
480
478
UpdateOverallDiagnosticResult (failed);
481
479
}
@@ -498,25 +496,36 @@ void DiagnosticsDialog::on_testButton_clicked()
498
496
else if (connections >= 8 )
499
497
{
500
498
ui->verifyConnectionsResultLabel ->setText (tr (" Passed: Count = %1" ).arg (QString::number (connections)));
501
- ui->verifyConnectionsResultLabel ->setStyleSheet (" color:black ;background-color:green" );
499
+ ui->verifyConnectionsResultLabel ->setStyleSheet (" color:white ;background-color:green" );
502
500
UpdateTestStatus (" verifyConnections" , completed);
503
501
UpdateOverallDiagnosticResult (passed);
504
502
}
505
503
else
506
504
{
507
505
ui->verifyConnectionsResultLabel ->setText (tr (" Failed: Count = %1" ).arg (QString::number (connections)));
508
- ui->verifyConnectionsResultLabel ->setStyleSheet (" color:black ;background-color:red" );
506
+ ui->verifyConnectionsResultLabel ->setStyleSheet (" color:white ;background-color:red" );
509
507
UpdateTestStatus (" verifyConnections" , completed);
510
508
UpdateOverallDiagnosticResult (failed);
511
509
}
512
510
513
511
// tcp port
514
- ui->verifyTCPPortResultLabel ->setStyleSheet (" " );
515
- ui->verifyTCPPortResultLabel ->setText (tr (" Testing..." ));
516
- UpdateTestStatus (" verifyTCPPort" , pending);
517
- this ->repaint ();
512
+ // Only test this if intention is to run a full node (i.e. listen=1).
513
+ if (GetArg (" -listen" , false ))
514
+ {
515
+ ui->verifyTCPPortResultLabel ->setStyleSheet (" " );
516
+ ui->verifyTCPPortResultLabel ->setText (tr (" Testing..." ));
517
+ UpdateTestStatus (" verifyTCPPort" , pending);
518
+ this ->repaint ();
518
519
519
- VerifyTCPPort ();
520
+ VerifyTCPPort ();
521
+ }
522
+ else
523
+ {
524
+ ui->verifyTCPPortResultLabel ->setText (tr (" NA" ));
525
+ ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black;background-color:grey" );
526
+ UpdateTestStatus (" verifyTCPPort" , completed);
527
+ UpdateOverallDiagnosticResult (NA);
528
+ }
520
529
521
530
// client version
522
531
ui->checkClientVersionResultLabel ->setStyleSheet (" " );
@@ -535,7 +544,7 @@ void DiagnosticsDialog::on_testButton_clicked()
535
544
else
536
545
{
537
546
ui->checkClientVersionResultLabel ->setText (tr (" Passed" ));
538
- ui->checkClientVersionResultLabel ->setStyleSheet (" color:black ;background-color:green" );
547
+ ui->checkClientVersionResultLabel ->setStyleSheet (" color:white ;background-color:green" );
539
548
UpdateTestStatus (" checkClientVersion" , completed);
540
549
UpdateOverallDiagnosticResult (passed);
541
550
}
@@ -549,7 +558,7 @@ void DiagnosticsDialog::VerifyClock()
549
558
udpSocket = new QUdpSocket (this );
550
559
551
560
connect (udpSocket, SIGNAL (stateChanged (QAbstractSocket::SocketState)), this , SLOT (clkStateChanged (QAbstractSocket::SocketState)));
552
- connect (udpSocket, SIGNAL (error (QAbstractSocket::SocketError)), this , SLOT (clkSocketError (QAbstractSocket::SocketError )));
561
+ connect (udpSocket, SIGNAL (error (QAbstractSocket::SocketError)), this , SLOT (clkSocketError ()));
553
562
554
563
udpSocket->bind (QHostAddress (NTPHost.addresses ().first ()), 123 , QAbstractSocket::ShareAddress);
555
564
udpSocket->connectToHost (QHostAddress (NTPHost.addresses ().first ()), 123 , QIODevice::ReadWrite);
@@ -569,27 +578,21 @@ void DiagnosticsDialog::clkStateChanged(QAbstractSocket::SocketState state)
569
578
return ;
570
579
}
571
580
572
- void DiagnosticsDialog::clkSocketError (QAbstractSocket::SocketError error )
581
+ void DiagnosticsDialog::clkSocketError ()
573
582
{
574
583
udpSocket->close ();
575
584
576
- ui->verifyClockResultLabel ->setText (tr (" Warning: Cannot connect to NTP server" ));
577
- ui->verifyClockResultLabel ->setStyleSheet (" color:black;background-color:yellow" );
578
- UpdateTestStatus (" verifyClockResult" , completed);
579
-
580
- // We need this here because there is no return call (callback) to the on_testButton_clicked function
581
- UpdateOverallDiagnosticResult (warning);
582
-
583
- DisplayOverallDiagnosticResult ();
584
-
585
585
return ;
586
586
}
587
587
588
588
void DiagnosticsDialog::clkFinished ()
589
589
{
590
590
if (udpSocket->waitForReadyRead ())
591
591
{
592
- while (udpSocket->hasPendingDatagrams ())
592
+ int64_t start_time = GetAdjustedTime ();
593
+
594
+ // Only allow this loop to run for 15 seconds maximum.
595
+ while (udpSocket->hasPendingDatagrams () && GetAdjustedTime () - start_time <= 15 )
593
596
{
594
597
QByteArray BufferSocket = udpSocket->readAll ();
595
598
@@ -609,7 +612,7 @@ void DiagnosticsDialog::clkFinished()
609
612
if (timeDiff.minutes () < 3 )
610
613
{
611
614
ui->verifyClockResultLabel ->setText (tr (" Passed" ));
612
- ui->verifyClockResultLabel ->setStyleSheet (" color:black ;background-color:green" );
615
+ ui->verifyClockResultLabel ->setStyleSheet (" color:white ;background-color:green" );
613
616
UpdateTestStatus (" verifyClockResult" , completed);
614
617
615
618
// We need this here because there is no return call (callback) to the on_testButton_clicked function
@@ -618,20 +621,33 @@ void DiagnosticsDialog::clkFinished()
618
621
else
619
622
{
620
623
ui->verifyClockResultLabel ->setText (tr (" Failed: Sync local time with network" ));
621
- ui->verifyClockResultLabel ->setStyleSheet (" color:black ;background-color:red" );
624
+ ui->verifyClockResultLabel ->setStyleSheet (" color:white ;background-color:red" );
622
625
UpdateTestStatus (" verifyClockResult" , completed);
623
626
624
627
// We need this here because there is no return call (callback) to the on_testButton_clicked function
625
628
UpdateOverallDiagnosticResult (failed);
626
629
}
630
+
631
+ // We need this here because there is no return call (callback) to the on_testButton_clicked function
632
+ DisplayOverallDiagnosticResult ();
633
+
634
+ return ;
627
635
}
628
636
}
629
637
}
638
+ else // The other state here is a socket or other indeterminate error (coming from clkSocketError).
639
+ {
640
+ ui->verifyClockResultLabel ->setText (tr (" Warning: Cannot connect to NTP server" ));
641
+ ui->verifyClockResultLabel ->setStyleSheet (" color:black;background-color:yellow" );
642
+ UpdateTestStatus (" verifyClockResult" , completed);
630
643
631
- // We need this here because there is no return call (callback) to the on_testButton_clicked function
632
- DisplayOverallDiagnosticResult ( );
644
+ // We need this here because there is no return call (callback) to the on_testButton_clicked function
645
+ UpdateOverallDiagnosticResult (warning );
633
646
634
- return ;
647
+ DisplayOverallDiagnosticResult ();
648
+
649
+ return ;
650
+ }
635
651
}
636
652
637
653
void DiagnosticsDialog::VerifyTCPPort ()
@@ -648,7 +664,7 @@ void DiagnosticsDialog::TCPFinished()
648
664
{
649
665
tcpSocket->close ();
650
666
ui->verifyTCPPortResultLabel ->setText (tr (" Passed" ));
651
- ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black ;background-color:green" );
667
+ ui->verifyTCPPortResultLabel ->setStyleSheet (" color:white ;background-color:green" );
652
668
653
669
// We need this here because there is no return call (callback) to the on_testButton_clicked function
654
670
UpdateTestStatus (" verifyTCPPort" , completed);
@@ -661,8 +677,8 @@ void DiagnosticsDialog::TCPFinished()
661
677
662
678
void DiagnosticsDialog::TCPFailed (QAbstractSocket::SocketError socket)
663
679
{
664
- ui->verifyTCPPortResultLabel ->setText (tr (" Failed : Port 32749 may be blocked by your firewall" ));
665
- ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black;background-color:red " );
680
+ ui->verifyTCPPortResultLabel ->setText (tr (" Warning : Port 32749 may be blocked by your firewall" ));
681
+ ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black;background-color:yellow " );
666
682
667
683
// We need this here because there is no return call (callback) to the on_testButton_clicked function
668
684
UpdateTestStatus (" verifyTCPPort" , completed);
0 commit comments