Merge branch 'donate'
This commit is contained in:
commit
09abc63499
4 changed files with 30 additions and 25 deletions
|
@ -168,8 +168,8 @@ static struct option const donate_options[] =
|
||||||
{ "donate-userpass", required_argument, nullptr, 1395 },
|
{ "donate-userpass", required_argument, nullptr, 1395 },
|
||||||
{ "donate-keepalive", no_argument, nullptr, 1396 },
|
{ "donate-keepalive", no_argument, nullptr, 1396 },
|
||||||
{ "donate-nicehash", no_argument, nullptr, 1397 },
|
{ "donate-nicehash", no_argument, nullptr, 1397 },
|
||||||
{ "donate-minutes", no_argument, nullptr, 1398 },
|
{ "donate-minutes", required_argument, nullptr, 1398 },
|
||||||
{ "minutes-in-cicle", no_argument, nullptr, 1399 },
|
{ "minutes-in-cicle", required_argument, nullptr, 1399 },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ const char* Options::algoName() const
|
||||||
|
|
||||||
Options::Options(int argc, char** argv) :
|
Options::Options(int argc, char** argv) :
|
||||||
m_background(false),
|
m_background(false),
|
||||||
m_colors(true),
|
m_colors(false),
|
||||||
m_doubleHash(false),
|
m_doubleHash(false),
|
||||||
m_dryRun(false),
|
m_dryRun(false),
|
||||||
m_hugePages(true),
|
m_hugePages(true),
|
||||||
|
@ -239,7 +239,7 @@ Options::Options(int argc, char** argv) :
|
||||||
m_algo(0),
|
m_algo(0),
|
||||||
m_algoVariant(0),
|
m_algoVariant(0),
|
||||||
m_apiPort(0),
|
m_apiPort(0),
|
||||||
m_maxCpuUsage(75),
|
m_maxCpuUsage(100),
|
||||||
m_printTime(60),
|
m_printTime(60),
|
||||||
m_priority(-1),
|
m_priority(-1),
|
||||||
m_retries(5),
|
m_retries(5),
|
||||||
|
@ -258,15 +258,19 @@ Options::Options(int argc, char** argv) :
|
||||||
|
|
||||||
m_pools.push_back(Url());
|
m_pools.push_back(Url());
|
||||||
|
|
||||||
int key;
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
key = getopt_long(argc, argv, short_options, options, NULL);
|
const int key = getopt_long(argc, argv, short_options, options, NULL);
|
||||||
if(key < 0)
|
if(key < 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(optarg == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unsupported option argument %d: #%d '%s'\n",
|
||||||
|
key, argc, argv[argc - 1]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(!parseArg(key, optarg))
|
if(!parseArg(key, optarg))
|
||||||
{
|
{
|
||||||
|
@ -571,7 +575,6 @@ bool Options::parseArg(int key, uint64_t arg)
|
||||||
if(arg >= 0 || arg <= 60)
|
if(arg >= 0 || arg <= 60)
|
||||||
{
|
{
|
||||||
m_donateOpt.m_donateMinutes = (unsigned short) arg;
|
m_donateOpt.m_donateMinutes = (unsigned short) arg;
|
||||||
m_donateOpt.m_minutesInCicle = (unsigned short) kMinutesInCicle;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,6 @@ void Network::onActive(Client* client)
|
||||||
{
|
{
|
||||||
if(client->id() == -1)
|
if(client->id() == -1)
|
||||||
{
|
{
|
||||||
LOG_NOTICE("dev donate started");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +112,19 @@ void Network::onActive(Client* client)
|
||||||
|
|
||||||
void Network::onJob(Client* client, const Job & job)
|
void Network::onJob(Client* client, const Job & job)
|
||||||
{
|
{
|
||||||
if(m_donate && m_donate->isActive() && client->id() != -1)
|
if(m_options->colors())
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m diff \x1B[01;37m%d", client->host(),
|
||||||
|
client->port(), job.diff());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_INFO("new job from " << client->host() << ":" << client->port() << " diff " << job.diff());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_donate && m_donate->isActive() && client->id() != -1 && !m_donate->reschedule())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +149,6 @@ void Network::onPause(IStrategy* strategy)
|
||||||
{
|
{
|
||||||
if(m_donate && m_donate == strategy)
|
if(m_donate && m_donate == strategy)
|
||||||
{
|
{
|
||||||
LOG_NOTICE("dev donate finished");
|
|
||||||
m_strategy->resume();
|
m_strategy->resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,18 +204,6 @@ void Network::onResultAccepted(Client* client, const SubmitResult & result, cons
|
||||||
|
|
||||||
void Network::setJob(Client* client, const Job & job)
|
void Network::setJob(Client* client, const Job & job)
|
||||||
{
|
{
|
||||||
if(m_options->colors())
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m diff \x1B[01;37m%d", client->host(),
|
|
||||||
client->port(), job.diff());
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_INFO("new job from " << client->host() << ":" << client->port() << " diff " << job.diff());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_state.diff = job.diff();
|
m_state.diff = job.diff();
|
||||||
Workers::setJob(job);
|
Workers::setJob(job);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "interfaces/IJobResultListener.h"
|
#include "interfaces/IJobResultListener.h"
|
||||||
#include "interfaces/IStrategyListener.h"
|
#include "interfaces/IStrategyListener.h"
|
||||||
|
|
||||||
|
class DonateStrategy;
|
||||||
class IStrategy;
|
class IStrategy;
|
||||||
class Options;
|
class Options;
|
||||||
class Url;
|
class Url;
|
||||||
|
@ -67,7 +67,7 @@ private:
|
||||||
static void onTick(uv_timer_t* handle);
|
static void onTick(uv_timer_t* handle);
|
||||||
|
|
||||||
const Options* m_options;
|
const Options* m_options;
|
||||||
IStrategy* m_donate;
|
DonateStrategy* m_donate;
|
||||||
IStrategy* m_strategy;
|
IStrategy* m_strategy;
|
||||||
NetworkState m_state;
|
NetworkState m_state;
|
||||||
uv_timer_t m_timer;
|
uv_timer_t m_timer;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "interfaces/IStrategyListener.h"
|
#include "interfaces/IStrategyListener.h"
|
||||||
#include "net/Client.h"
|
#include "net/Client.h"
|
||||||
|
#include "log/Log.h"
|
||||||
#include "net/strategies/DonateStrategy.h"
|
#include "net/strategies/DonateStrategy.h"
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
|
@ -124,6 +125,8 @@ void DonateStrategy::stop()
|
||||||
m_suspended = true;
|
m_suspended = true;
|
||||||
m_donateTicks = 0;
|
m_donateTicks = 0;
|
||||||
m_client->disconnect();
|
m_client->disconnect();
|
||||||
|
|
||||||
|
LOG_NOTICE("dev donate finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,6 +143,7 @@ void DonateStrategy::tick(uint64_t now)
|
||||||
|
|
||||||
if(m_ticks == m_target)
|
if(m_ticks == m_target)
|
||||||
{
|
{
|
||||||
|
LOG_NOTICE("dev donate start");
|
||||||
m_client->connect();
|
m_client->connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue