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,9 +558,8 @@ 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
- udpSocket->bind (QHostAddress (NTPHost.addresses ().first ()), 123 , QAbstractSocket::ShareAddress);
555
563
udpSocket->connectToHost (QHostAddress (NTPHost.addresses ().first ()), 123 , QIODevice::ReadWrite);
556
564
}
557
565
@@ -569,27 +577,21 @@ void DiagnosticsDialog::clkStateChanged(QAbstractSocket::SocketState state)
569
577
return ;
570
578
}
571
579
572
- void DiagnosticsDialog::clkSocketError (QAbstractSocket::SocketError error )
580
+ void DiagnosticsDialog::clkSocketError ()
573
581
{
574
582
udpSocket->close ();
575
583
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
584
return ;
586
585
}
587
586
588
587
void DiagnosticsDialog::clkFinished ()
589
588
{
590
589
if (udpSocket->waitForReadyRead ())
591
590
{
592
- while (udpSocket->hasPendingDatagrams ())
591
+ int64_t start_time = GetAdjustedTime ();
592
+
593
+ // Only allow this loop to run for 15 seconds maximum.
594
+ while (udpSocket->hasPendingDatagrams () && GetAdjustedTime () - start_time <= 15 )
593
595
{
594
596
QByteArray BufferSocket = udpSocket->readAll ();
595
597
@@ -609,7 +611,7 @@ void DiagnosticsDialog::clkFinished()
609
611
if (timeDiff.minutes () < 3 )
610
612
{
611
613
ui->verifyClockResultLabel ->setText (tr (" Passed" ));
612
- ui->verifyClockResultLabel ->setStyleSheet (" color:black ;background-color:green" );
614
+ ui->verifyClockResultLabel ->setStyleSheet (" color:white ;background-color:green" );
613
615
UpdateTestStatus (" verifyClockResult" , completed);
614
616
615
617
// We need this here because there is no return call (callback) to the on_testButton_clicked function
@@ -618,20 +620,33 @@ void DiagnosticsDialog::clkFinished()
618
620
else
619
621
{
620
622
ui->verifyClockResultLabel ->setText (tr (" Failed: Sync local time with network" ));
621
- ui->verifyClockResultLabel ->setStyleSheet (" color:black ;background-color:red" );
623
+ ui->verifyClockResultLabel ->setStyleSheet (" color:white ;background-color:red" );
622
624
UpdateTestStatus (" verifyClockResult" , completed);
623
625
624
626
// We need this here because there is no return call (callback) to the on_testButton_clicked function
625
627
UpdateOverallDiagnosticResult (failed);
626
628
}
629
+
630
+ // We need this here because there is no return call (callback) to the on_testButton_clicked function
631
+ DisplayOverallDiagnosticResult ();
632
+
633
+ return ;
627
634
}
628
635
}
629
636
}
637
+ else // The other state here is a socket or other indeterminate error (coming from clkSocketError).
638
+ {
639
+ ui->verifyClockResultLabel ->setText (tr (" Warning: Cannot connect to NTP server" ));
640
+ ui->verifyClockResultLabel ->setStyleSheet (" color:black;background-color:yellow" );
641
+ UpdateTestStatus (" verifyClockResult" , completed);
630
642
631
- // We need this here because there is no return call (callback) to the on_testButton_clicked function
632
- DisplayOverallDiagnosticResult ( );
643
+ // We need this here because there is no return call (callback) to the on_testButton_clicked function
644
+ UpdateOverallDiagnosticResult (warning );
633
645
634
- return ;
646
+ DisplayOverallDiagnosticResult ();
647
+
648
+ return ;
649
+ }
635
650
}
636
651
637
652
void DiagnosticsDialog::VerifyTCPPort ()
@@ -648,7 +663,7 @@ void DiagnosticsDialog::TCPFinished()
648
663
{
649
664
tcpSocket->close ();
650
665
ui->verifyTCPPortResultLabel ->setText (tr (" Passed" ));
651
- ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black ;background-color:green" );
666
+ ui->verifyTCPPortResultLabel ->setStyleSheet (" color:white ;background-color:green" );
652
667
653
668
// We need this here because there is no return call (callback) to the on_testButton_clicked function
654
669
UpdateTestStatus (" verifyTCPPort" , completed);
@@ -661,8 +676,8 @@ void DiagnosticsDialog::TCPFinished()
661
676
662
677
void DiagnosticsDialog::TCPFailed (QAbstractSocket::SocketError socket)
663
678
{
664
- ui->verifyTCPPortResultLabel ->setText (tr (" Failed : Port 32749 may be blocked by your firewall" ));
665
- ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black;background-color:red " );
679
+ ui->verifyTCPPortResultLabel ->setText (tr (" Warning : Port 32749 may be blocked by your firewall" ));
680
+ ui->verifyTCPPortResultLabel ->setStyleSheet (" color:black;background-color:yellow " );
666
681
667
682
// We need this here because there is no return call (callback) to the on_testButton_clicked function
668
683
UpdateTestStatus (" verifyTCPPort" , completed);
0 commit comments