Skip to content

Commit

Permalink
Added "-r" switch to specify reward address in solo mining mode
Browse files Browse the repository at this point in the history
  • Loading branch information
psolstice committed Sep 13, 2021
1 parent a24e8a1 commit f0fee99
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions firominer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ class MinerCLI
vector<string> pools;
app.add_option("-P,--pool", pools, "");

string rewardAddress;
app.add_option("-r,--reward-address", m_PoolSettings.rewardAddress, "");

app.add_option("--failover-timeout", m_PoolSettings.poolFailoverTimeout, "", true)
->check(CLI::Range(0, 999));

Expand Down Expand Up @@ -370,6 +373,8 @@ class MinerCLI
app.add_option("--tstop", m_FarmSettings.tempStop, "", true)->check(CLI::Range(30, 100));
app.add_option("--tstart", m_FarmSettings.tempStart, "", true)->check(CLI::Range(30, 100));

// add reward address option


// Exception handling is held at higher level
app.parse(argc, argv);
Expand Down
2 changes: 1 addition & 1 deletion libpoolprotocols/PoolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void PoolManager::rotateConnect()

if (m_Settings.connections.at(m_activeConnectionIdx)->Family() == ProtocolFamily::GETWORK)
p_client = std::unique_ptr<PoolClient>(
new EthGetworkClient(m_Settings.noWorkTimeout, m_Settings.getWorkPollInterval));
new EthGetworkClient(m_Settings.noWorkTimeout, m_Settings.getWorkPollInterval, m_Settings.rewardAddress));
if (m_Settings.connections.at(m_activeConnectionIdx)->Family() == ProtocolFamily::STRATUM)
p_client = std::unique_ptr<PoolClient>(
new EthStratumClient(m_Settings.noWorkTimeout, m_Settings.noResponseTimeout));
Expand Down
1 change: 1 addition & 0 deletions libpoolprotocols/PoolManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct PoolSettings
unsigned connectionMaxRetries = 9000; // Max number of connection retries
unsigned benchmarkBlock = 0; // Block number used by SimulateClient to test performances
float benchmarkDiff = 1.0; // Difficulty used by SimulateClient to test performances
std::string rewardAddress; // Reward address in case of solo mining
};

class PoolManager
Expand Down
9 changes: 7 additions & 2 deletions libpoolprotocols/getwork/EthGetworkClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace eth;

using boost::asio::ip::tcp;

EthGetworkClient::EthGetworkClient(int worktimeout, unsigned farmRecheckPeriod)
EthGetworkClient::EthGetworkClient(int worktimeout, unsigned farmRecheckPeriod, const std::string &rewardAddress)
: PoolClient(),
m_farmRecheckPeriod(farmRecheckPeriod),
m_io_strand(g_io_service),
Expand All @@ -27,7 +27,12 @@ EthGetworkClient::EthGetworkClient(int worktimeout, unsigned farmRecheckPeriod)
jGetWork["id"] = unsigned(1);
jGetWork["jsonrpc"] = "2.0";
jGetWork["method"] = "getblocktemplate";
jGetWork["params"] = Json::Value(Json::arrayValue);

Json::Value params = Json::Value(Json::arrayValue);
params.append(Json::Value(Json::objectValue));
params.append(rewardAddress);
jGetWork["params"] = params;

m_jsonGetWork = std::string(Json::writeString(m_jSwBuilder, jGetWork));
}

Expand Down
2 changes: 1 addition & 1 deletion libpoolprotocols/getwork/EthGetworkClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace eth;
class EthGetworkClient : public PoolClient
{
public:
EthGetworkClient(int worktimeout, unsigned farmRecheckPeriod);
EthGetworkClient(int worktimeout, unsigned farmRecheckPeriod, const std::string &rewardAddress);
~EthGetworkClient();

void connect() override;
Expand Down

0 comments on commit f0fee99

Please sign in to comment.