@@ -447,7 +447,7 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
447
447
// Gives nonce scrambler a new range
448
448
cnote << " Miner Shuffle requested" ;
449
449
jResponse[" result" ] = true ;
450
- g_farm-> shuffle ();
450
+ Farm::f (). shuffle ();
451
451
}
452
452
453
453
else if (_method == " miner_ping" )
@@ -465,7 +465,7 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
465
465
return ;
466
466
cnote << " Miner Restart requested" ;
467
467
jResponse[" result" ] = true ;
468
- g_farm-> restart_async ();
468
+ Farm::f (). restart_async ();
469
469
}
470
470
471
471
else if (_method == " miner_reboot" )
@@ -474,13 +474,13 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
474
474
return ;
475
475
cnote << " Miner reboot requested" ;
476
476
477
- jResponse[" result" ] = g_farm-> reboot ({{" api_miner_reboot" }});
477
+ jResponse[" result" ] = Farm::f (). reboot ({{" api_miner_reboot" }});
478
478
}
479
479
480
480
else if (_method == " miner_getconnections" )
481
481
{
482
482
// Returns a list of configured pools
483
- jResponse[" result" ] = g_mgr-> getConnectionsJson ();
483
+ jResponse[" result" ] = PoolManager::p (). getConnectionsJson ();
484
484
}
485
485
486
486
else if (_method == " miner_addconnection" )
@@ -513,7 +513,7 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
513
513
}
514
514
515
515
// Check other pools already present share the same scheme family (stratum or getwork)
516
- Json::Value pools = g_mgr-> getConnectionsJson ();
516
+ Json::Value pools = PoolManager::p (). getConnectionsJson ();
517
517
for (Json::Value::ArrayIndex i = 0 ; i != pools.size (); i++)
518
518
{
519
519
dev::URI poolUri = pools[i][" uri" ].asString ();
@@ -527,7 +527,7 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
527
527
}
528
528
529
529
// If everything ok then add this new uri
530
- g_mgr-> addConnection (uri);
530
+ PoolManager::p (). addConnection (uri);
531
531
jResponse[" result" ] = true ;
532
532
}
533
533
catch (...)
@@ -550,15 +550,15 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
550
550
if (!getRequestValue (" index" , index , jRequestParams, false , jResponse))
551
551
return ;
552
552
553
- Json::Value pools = g_mgr-> getConnectionsJson ();
553
+ Json::Value pools = PoolManager::p (). getConnectionsJson ();
554
554
if (index >= pools.size ())
555
555
{
556
556
jResponse[" error" ][" code" ] = -422 ;
557
557
jResponse[" error" ][" message" ] = " Index out of bounds" ;
558
558
return ;
559
559
}
560
560
561
- g_mgr-> setActiveConnection (index );
561
+ PoolManager::p (). setActiveConnection (index );
562
562
jResponse[" result" ] = true ;
563
563
}
564
564
@@ -575,7 +575,7 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
575
575
if (!getRequestValue (" index" , index , jRequestParams, false , jResponse))
576
576
return ;
577
577
578
- Json::Value pools = g_mgr-> getConnectionsJson ();
578
+ Json::Value pools = PoolManager::p (). getConnectionsJson ();
579
579
if (index >= pools.size ())
580
580
{
581
581
jResponse[" error" ][" code" ] = -422 ;
@@ -589,13 +589,13 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
589
589
return ;
590
590
}
591
591
592
- g_mgr-> removeConnection (index );
592
+ PoolManager::p (). removeConnection (index );
593
593
jResponse[" result" ] = true ;
594
594
}
595
595
596
596
else if (_method == " miner_getscramblerinfo" )
597
597
{
598
- jResponse[" result" ] = g_farm-> get_nonce_scrambler_json ();
598
+ jResponse[" result" ] = Farm::f (). get_nonce_scrambler_json ();
599
599
}
600
600
601
601
else if (_method == " miner_setscramblerinfo" )
@@ -608,8 +608,8 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
608
608
return ;
609
609
610
610
bool any_value_provided = false ;
611
- uint64_t nonce = g_farm-> get_nonce_scrambler ();
612
- unsigned exp = g_farm-> get_segment_width ();
611
+ uint64_t nonce = Farm::f (). get_nonce_scrambler ();
612
+ unsigned exp = Farm::f (). get_segment_width ();
613
613
614
614
if (!getRequestValue (" noncescrambler" , nonce, jRequestParams, true , jResponse))
615
615
return ;
@@ -630,8 +630,8 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
630
630
exp = 10 ; // Not below
631
631
if (exp > 50 )
632
632
exp = 40 ; // Not above
633
- g_farm-> set_nonce_scrambler (nonce);
634
- g_farm-> set_nonce_segment_width (exp );
633
+ Farm::f (). set_nonce_scrambler (nonce);
634
+ Farm::f (). set_nonce_segment_width (exp );
635
635
jResponse[" result" ] = true ;
636
636
}
637
637
@@ -652,15 +652,15 @@ void ApiConnection::processRequest(Json::Value& jRequest, Json::Value& jResponse
652
652
if (!getRequestValue (" pause" , pause , jRequestParams, false , jResponse))
653
653
return ;
654
654
655
- WorkingProgress p = g_farm-> miningProgress ();
655
+ WorkingProgress p = Farm::f (). miningProgress ();
656
656
if (index >= p.miningIsPaused .size ())
657
657
{
658
658
jResponse[" error" ][" code" ] = -422 ;
659
659
jResponse[" error" ][" message" ] = " Index out of bounds" ;
660
660
return ;
661
661
}
662
662
663
- auto const & miner = g_farm-> getMiner (index );
663
+ auto const & miner = Farm::f (). getMiner (index );
664
664
if (miner)
665
665
{
666
666
if (pause )
@@ -794,10 +794,10 @@ void ApiConnection::onSendSocketDataCompleted(const boost::system::error_code& e
794
794
Json::Value ApiConnection::getMinerStat1 ()
795
795
{
796
796
auto runningTime = std::chrono::duration_cast<std::chrono::minutes>(
797
- steady_clock::now () - g_farm-> farmLaunched ());
798
- auto connection = g_mgr-> getActiveConnectionCopy ();
799
- SolutionStats s = g_farm-> getSolutionStats ();
800
- WorkingProgress p = g_farm-> miningProgress ();
797
+ steady_clock::now () - Farm::f (). farmLaunched ());
798
+ auto connection = PoolManager::p (). getActiveConnectionCopy ();
799
+ SolutionStats s = Farm::f (). getSolutionStats ();
800
+ WorkingProgress p = Farm::f (). miningProgress ();
801
801
802
802
ostringstream totalMhEth;
803
803
ostringstream totalMhDcr;
@@ -857,10 +857,10 @@ Json::Value ApiConnection::getMinerStatHR()
857
857
{
858
858
// TODO:give key-value format
859
859
auto runningTime = std::chrono::duration_cast<std::chrono::minutes>(
860
- steady_clock::now () - g_farm-> farmLaunched ());
861
- auto connection = g_mgr-> getActiveConnectionCopy ();
862
- SolutionStats s = g_farm-> getSolutionStats ();
863
- WorkingProgress p = g_farm-> miningProgress ();
860
+ steady_clock::now () - Farm::f (). farmLaunched ());
861
+ auto connection = PoolManager::p (). getActiveConnectionCopy ();
862
+ SolutionStats s = Farm::f (). getSolutionStats ();
863
+ WorkingProgress p = Farm::f (). miningProgress ();
864
864
865
865
ostringstream version;
866
866
ostringstream runtime;
@@ -928,7 +928,7 @@ Json::Value ApiConnection::getMinerStatDetailPerMiner(
928
928
const WorkingProgress& p, const SolutionStats& s, size_t index)
929
929
{
930
930
Json::Value jRes;
931
- auto const & miner = g_farm-> getMiner (index );
931
+ auto const & miner = Farm::f (). getMiner (index );
932
932
933
933
jRes[" index" ] = (unsigned )index ;
934
934
@@ -977,8 +977,8 @@ Json::Value ApiConnection::getMinerStatDetailPerMiner(
977
977
}
978
978
979
979
/* Nonce infos */
980
- auto segment_width = g_farm-> get_segment_width ();
981
- uint64_t gpustartnonce = g_farm-> get_nonce_scrambler () + ((uint64_t )index << segment_width);
980
+ auto segment_width = Farm::f (). get_segment_width ();
981
+ uint64_t gpustartnonce = Farm::f (). get_nonce_scrambler () + ((uint64_t )index << segment_width);
982
982
jRes[" nonce_start" ] = gpustartnonce;
983
983
jRes[" nonce_stop" ] = uint64_t (gpustartnonce + (1LL << segment_width));
984
984
@@ -998,11 +998,11 @@ Json::Value ApiConnection::getMinerStatDetailPerMiner(
998
998
Json::Value ApiConnection::getMinerStatDetail ()
999
999
{
1000
1000
auto runningTime = std::chrono::duration_cast<std::chrono::minutes>(
1001
- std::chrono::steady_clock::now () - g_farm-> farmLaunched ());
1001
+ std::chrono::steady_clock::now () - Farm::f (). farmLaunched ());
1002
1002
1003
- SolutionStats s = g_farm-> getSolutionStats ();
1004
- WorkingProgress p = g_farm-> miningProgress ();
1005
- WorkPackage w = g_farm-> work ();
1003
+ SolutionStats s = Farm::f (). getSolutionStats ();
1004
+ WorkingProgress p = Farm::f (). miningProgress ();
1005
+ WorkPackage w = Farm::f (). work ();
1006
1006
1007
1007
// ostringstream version;
1008
1008
Json::Value gpus;
@@ -1021,27 +1021,27 @@ Json::Value ApiConnection::getMinerStatDetail()
1021
1021
}
1022
1022
1023
1023
/* connection info */
1024
- auto connection = g_mgr-> getActiveConnectionCopy ();
1024
+ auto connection = PoolManager::p (). getActiveConnectionCopy ();
1025
1025
Json::Value jconnection;
1026
1026
jconnection[" uri" ] = connection.String ();
1027
- // jconnection["endpoint"] = g_mgr-> getClient()->ActiveEndPoint();
1028
- jconnection[" isconnected" ] = g_mgr-> isConnected ();
1029
- jconnection[" switched" ] = g_mgr-> getConnectionSwitches ();
1027
+ // jconnection["endpoint"] = PoolManager::p(). getClient()->ActiveEndPoint();
1028
+ jconnection[" isconnected" ] = PoolManager::p (). isConnected ();
1029
+ jconnection[" switched" ] = PoolManager::p (). getConnectionSwitches ();
1030
1030
jRes[" connection" ] = jconnection;
1031
1031
1032
1032
/* Pool info */
1033
- jRes[" difficulty" ] = g_mgr-> getCurrentDifficulty ();
1033
+ jRes[" difficulty" ] = PoolManager::p (). getCurrentDifficulty ();
1034
1034
if (w)
1035
1035
jRes[" epoch" ] = w.epoch ;
1036
1036
else
1037
1037
jRes[" epoch" ] = Json::Value::null;
1038
- jRes[" epoch_changes" ] = g_mgr-> getEpochChanges ();
1038
+ jRes[" epoch_changes" ] = PoolManager::p (). getEpochChanges ();
1039
1039
1040
1040
/* basic setup */
1041
- auto tstop = g_farm-> get_tstop ();
1041
+ auto tstop = Farm::f (). get_tstop ();
1042
1042
if (tstop)
1043
1043
{
1044
- jRes[" tstart" ] = g_farm-> get_tstart ();
1044
+ jRes[" tstart" ] = Farm::f (). get_tstart ();
1045
1045
jRes[" tstop" ] = tstop;
1046
1046
}
1047
1047
else
@@ -1050,9 +1050,9 @@ Json::Value ApiConnection::getMinerStatDetail()
1050
1050
}
1051
1051
1052
1052
/* gpu related info */
1053
- if (g_farm-> getMiners ().size ())
1053
+ if (Farm::f (). getMiners ().size ())
1054
1054
{
1055
- for (size_t i = 0 ; i < g_farm-> getMiners ().size (); i++)
1055
+ for (size_t i = 0 ; i < Farm::f (). getMiners ().size (); i++)
1056
1056
{
1057
1057
jRes[" gpus" ].append (getMinerStatDetailPerMiner (p, s, i));
1058
1058
}
0 commit comments