Merge pull request #3 from ekimmo/master

Mining protocol made compatible with MinerGate.com
This commit is contained in:
amjuarez 2014-04-21 12:27:37 +00:00
commit ce93a356d0
3 changed files with 20 additions and 5 deletions

View file

@ -856,7 +856,7 @@ using namespace std;
http::url_content u_c;
bool res = parse_url(url, u_c);
if(!tr.is_connected())
if(!tr.is_connected() && !u_c.host.empty())
{
CHECK_AND_ASSERT_MES(res, false, "failed to parse url: " << url);

View file

@ -2,7 +2,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "common/command_line.h"
#include "misc_log_ex.h"
#include "simpleminer.h"
@ -120,6 +119,7 @@ namespace mining
COMMAND_RPC_LOGIN::request req = AUTO_VAL_INIT(req);
req.login = m_login;
req.pass = m_pass;
req.agent = "simpleminer/0.1";
COMMAND_RPC_LOGIN::response resp = AUTO_VAL_INIT(resp);
if(!epee::net_utils::invoke_http_json_rpc<mining::COMMAND_RPC_LOGIN>("/", req, resp, m_http_client))
{
@ -137,7 +137,12 @@ namespace mining
}
pool_session_id = resp.id;
//78
if(!text_job_details_to_native_job_details(resp.job, job))
if (resp.job.blob.empty() && resp.job.target.empty() && resp.job.job_id.empty())
{
LOG_PRINT_L0("Job didn't change");
continue;
}
else if(!text_job_details_to_native_job_details(resp.job, job))
{
LOG_PRINT_L0("Failed to text_job_details_to_native_job_details(), disconnect and sleep....");
m_http_client.disconnect();
@ -161,7 +166,8 @@ namespace mining
COMMAND_RPC_SUBMITSHARE::response submit_response = AUTO_VAL_INIT(submit_response);
submit_request.id = pool_session_id;
submit_request.job_id = job.job_id;
submit_request.nonce = epee::string_tools::pod_to_hex((*((uint32_t*)&job.blob.data()[78])));
submit_request.nonce = epee::string_tools::pod_to_hex((*((uint32_t*)&job.blob.data()[39])));
submit_request.result = epee::string_tools::pod_to_hex(h);
LOG_PRINT_L0("Share found: nonce=" << submit_request.nonce << " for job=" << job.job_id << ", submitting...");
if(!epee::net_utils::invoke_http_json_rpc<mining::COMMAND_RPC_SUBMITSHARE>("/", submit_request, submit_response, m_http_client))
{
@ -193,7 +199,12 @@ namespace mining
epee::misc_utils::sleep_no_w(1000);
break;
}
if(!text_job_details_to_native_job_details(getjob_response, job))
if (getjob_response.blob.empty() && getjob_response.target.empty() && getjob_response.job_id.empty())
{
LOG_PRINT_L0("Job didn't change");
continue;
}
else if(!text_job_details_to_native_job_details(getjob_response, job))
{
LOG_PRINT_L0("Failed to text_job_details_to_native_job_details(), disconnect and sleep....");
m_http_client.disconnect();

View file

@ -36,10 +36,12 @@ namespace mining
{
std::string login;
std::string pass;
std::string agent;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(login)
KV_SERIALIZE(pass)
KV_SERIALIZE(agent)
END_KV_SERIALIZE_MAP()
};
@ -82,11 +84,13 @@ namespace mining
{
std::string id;
std::string nonce;
std::string result;
std::string job_id;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(id)
KV_SERIALIZE(nonce)
KV_SERIALIZE(result)
KV_SERIALIZE(job_id)
END_KV_SERIALIZE_MAP()
};