Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions xmrstak/cli/cli-miner.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ int main(int argc, char *argv[])
printer::inst()->print_str("'h' - hashrate\n");
printer::inst()->print_str("'r' - results\n");
printer::inst()->print_str("'c' - connection\n");
printer::inst()->print_str("'p' - reload pools\n");
printer::inst()->print_str("-------------------------------------------------------------------\n");
printer::inst()->print_msg(L0, "Mining coin: %s", jconf::inst()->GetMiningCoin().c_str());

Expand Down Expand Up @@ -814,6 +815,9 @@ int main(int argc, char *argv[])
case 'c':
executor::inst()->push_event(ex_event(EV_USR_CONNSTAT));
break;
case 'p':
executor::inst()->push_event(ex_event(EV_USR_POOLRELOAD));
break;
default:
break;
}
Expand Down
Empty file modified xmrstak/jconf.cpp
100644 → 100755
Empty file.
Empty file modified xmrstak/jconf.hpp
100644 → 100755
Empty file.
126 changes: 76 additions & 50 deletions xmrstak/misc/executor.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "xmrstak/donate-level.hpp"
#include "xmrstak/version.hpp"
#include "xmrstak/http/webdesign.hpp"
#include "xmrstak/params.hpp"

#include <thread>
#include <string>
Expand Down Expand Up @@ -487,26 +488,8 @@ void disable_sigpipe()
inline void disable_sigpipe() {}
#endif

void executor::ex_main()
{
disable_sigpipe();

assert(1000 % iTickTime == 0);

xmrstak::miner_work oWork = xmrstak::miner_work();

// \todo collect all backend threads
pvThreads = xmrstak::BackendConnector::thread_starter(oWork);

if(pvThreads->size()==0)
{
printer::inst()->print_msg(L1, "ERROR: No miner backend enabled.");
win_exit();
}

telem = new xmrstak::telemetry(pvThreads->size());

set_timestamp();
void executor::init_pools(void)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is not need for the explicit void

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed explicit void, however coming from embedded development for mission critical apps i always put void in the func that is not supposed to take any args, but this is in C :)

{
size_t pc = jconf::inst()->GetPoolCount();
bool dev_tls = true;
bool already_have_cli_pool = false;
Expand Down Expand Up @@ -539,6 +522,7 @@ void executor::ex_main()
else
pools.emplace_back(i+1, cfg.sPoolAddr, cfg.sWalletAddr, cfg.sRigId, cfg.sPasswd, cfg.weight, false, cfg.tls, cfg.tls_fingerprint, cfg.nicehash);
}


if(!xmrstak::params::inst().poolURL.empty() && !already_have_cli_pool)
{
Expand All @@ -551,42 +535,80 @@ void executor::ex_main()

pools.emplace_back(i+1, params.poolURL.c_str(), params.poolUsername.c_str(), params.poolRigid.c_str(), params.poolPasswd.c_str(), 9.9, false, params.poolUseTls, "", params.nicehashMode);
}

switch(jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgo())
{
case cryptonight_heavy:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8888", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:5555", "", "", "", 0.0, true, false, "", true);
break;
case cryptonight_heavy:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please remove all style changes that we can focus on the code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is fixed now

if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8888", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:5555", "", "", "", 0.0, true, false, "", true);
break;

case cryptonight_monero:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8800", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:5500", "", "", "", 0.0, true, false, "", false);
break;
case cryptonight_ipbc:
case cryptonight_aeon:
case cryptonight_lite:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:7777", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", "", 0.0, true, false, "", true);
break;
case cryptonight_monero:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:8800", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:5500", "", "", "", 0.0, true, false, "", false);
break;
case cryptonight_ipbc:
case cryptonight_aeon:
case cryptonight_lite:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:7777", "", "", "", 0.0, true, true, "", true);
else
pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", "", 0.0, true, false, "", true);
break;

case cryptonight:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:6666", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:3333", "", "", "", 0.0, true, false, "", false);
break;
case cryptonight:
if(dev_tls)
pools.emplace_front(0, "donate.xmr-stak.net:6666", "", "", "", 0.0, true, true, "", false);
else
pools.emplace_front(0, "donate.xmr-stak.net:3333", "", "", "", 0.0, true, false, "", false);
break;

default:
break;
default:
break;
}

}


void executor::on_pools_reload(void)
{
if(!jconf::inst()->parse_config(xmrstak::params::inst().configFile.c_str(), xmrstak::params::inst().configFilePools.c_str()))
printer::inst()->print_msg(L1, "ERROR: Failed to reload pools");
else
{
pools.clear();
init_pools();
printer::inst()->print_msg(L1, "Pool list updated");
}
}


void executor::ex_main()
{
disable_sigpipe();

assert(1000 % iTickTime == 0);

xmrstak::miner_work oWork = xmrstak::miner_work();

// \todo collect all backend threads
pvThreads = xmrstak::BackendConnector::thread_starter(oWork);

if(pvThreads->size()==0)
{
printer::inst()->print_msg(L1, "ERROR: No miner backend enabled.");
win_exit();
}

telem = new xmrstak::telemetry(pvThreads->size());

set_timestamp();
init_pools();

ex_event ev;
std::thread clock_thd(&executor::ex_clock_thd, this);

Expand All @@ -600,7 +622,7 @@ void executor::ex_main()
if(jconf::inst()->GetVerboseLevel() >= 4)
push_timed_event(ex_event(EV_HASHRATE_LOOP), jconf::inst()->GetAutohashTime());

size_t cnt = 0;
size_t cnt = 0,i=0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove i=0 it looks like it is not needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i is needed here because this variable is being used later on in one of the case statements in 2 places:

case EV_PERF_TICK:
for (i = 0; i < pvThreads->size(); i++)
telem->push_perf_value(i, pvThreads->at(i)->iHashCount.load(std::memory_order_relaxed),
pvThreads->at(i)->iTimestamp.load(std::memory_order_relaxed));

                    if((cnt++ & 0xF) == 0) //Every 16 ticks
                    {
                            double fHps = 0.0;
                            double fTelem;
                            bool normal = true;
                            for (i = 0; i < pvThreads->size(); i++)
                            {
                                    fTelem = telem->calc_telemetry_data(10000, i);
                                    if(std::isnormal(fTelem))
                                    {
                                            fHps += fTelem;
                                    }
                                    else
                                    {
                                            normal = false;
                                            break;
                                    }
                            }

                            if(normal && fHighestHps < fHps)
                                    fHighestHps = fHps;
                    }
                    break;

while (true)
{
ev = oEventQ.pop();
Expand Down Expand Up @@ -677,6 +699,10 @@ void executor::ex_main()
print_report(EV_USR_HASHRATE);
push_timed_event(ex_event(EV_HASHRATE_LOOP), jconf::inst()->GetAutohashTime());
break;

case EV_USR_POOLRELOAD:
on_pools_reload();
break;

case EV_INVALID_VAL:
default:
Expand Down
2 changes: 2 additions & 0 deletions xmrstak/misc/executor.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class executor
void connect_to_pools(std::list<jpsock*>& eval_pools);
bool get_live_pools(std::vector<jpsock*>& eval_pools, bool is_dev);
void eval_pool_choice();
void on_pools_reload(void);
void init_pools(void);

inline size_t sec_to_ticks(size_t sec) { return sec * (1000 / iTickTime); }
};
Expand Down
3 changes: 2 additions & 1 deletion xmrstak/net/msgstruct.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ struct gpu_res_err
enum ex_event_name { EV_INVALID_VAL, EV_SOCK_READY, EV_SOCK_ERROR, EV_GPU_RES_ERROR,
EV_POOL_HAVE_JOB, EV_MINER_HAVE_RESULT, EV_PERF_TICK, EV_EVAL_POOL_CHOICE,
EV_USR_HASHRATE, EV_USR_RESULTS, EV_USR_CONNSTAT, EV_HASHRATE_LOOP,
EV_HTML_HASHRATE, EV_HTML_RESULTS, EV_HTML_CONNSTAT, EV_HTML_JSON };
EV_HTML_HASHRATE, EV_HTML_RESULTS, EV_HTML_CONNSTAT, EV_HTML_JSON,
EV_USR_POOLRELOAD};

/*
This is how I learned to stop worrying and love c++11 =).
Expand Down