Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 037f7c6

Browse files
committedApr 6, 2018
Implement support for getwork miner id using URL path
ie. http://127.0.0.1:1234/miner1 Should work for both -F and -P parameters
1 parent 86bf1de commit 037f7c6

File tree

5 files changed

+45
-16
lines changed

5 files changed

+45
-16
lines changed
 

‎ethminer/MinerAux.h

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class MinerCLI
127127
if (uri.Host().length())
128128
{
129129
m_endpoints[k_primary_ep_ix].Host(uri.Host());
130+
m_endpoints[k_primary_ep_ix].Path(uri.Path());
130131
if (uri.Port())
131132
m_endpoints[k_primary_ep_ix].Port(uri.Port());
132133
else
@@ -157,6 +158,7 @@ class MinerCLI
157158
if (uri.Host().length())
158159
{
159160
m_endpoints[k_secondary_ep_ix].Host(uri.Host());
161+
m_endpoints[k_secondary_ep_ix].Path(uri.Path());
160162
if (m_mode == OperationMode::Stratum)
161163
{
162164
if (uri.Port())

‎libpoolprotocols/PoolClient.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@ namespace dev
1717
public:
1818
PoolConnection() {};
1919
PoolConnection(const URI &uri)
20-
: m_host(uri.Host()),
20+
: m_host(uri.Host()),
2121
m_port(uri.Port()),
2222
m_user(uri.User()),
2323
m_pass(uri.Pswd()),
2424
m_secLevel(uri.ProtoSecureLevel()),
25-
m_version(uri.ProtoVersion()) {};
25+
m_version(uri.ProtoVersion()),
26+
m_path(uri.Path()) {};
2627
string Host() const { return m_host; };
28+
string Path() const { return m_path; };
2729
unsigned short Port() const { return m_port; };
2830
string User() const { return m_user; };
2931
string Pass() const { return m_pass; };
3032
SecureLevel SecLevel() const { return m_secLevel; };
3133
boost::asio::ip::address Address() const { return m_address; };
3234
unsigned Version() const { return m_version; };
33-
3435

3536
void Host(string host) { m_host = host; };
37+
void Path(string path) { m_path = path; };
3638
void Port(unsigned short port) { m_port = port; };
3739
void User(string user) { m_user = user; };
3840
void Pass(string pass) { m_pass = pass; };
@@ -44,12 +46,13 @@ namespace dev
4446
// Normally we'd replace the following with a single URI variable
4547
// But URI attributes are read only, and to support legacy parameters
4648
// we need to update these connection attributes individually.
47-
string m_host;
49+
string m_host;
4850
unsigned short m_port = 0;
4951
string m_user;
5052
string m_pass;
5153
SecureLevel m_secLevel = SecureLevel::NONE;
5254
unsigned m_version = 0;
55+
string m_path;
5356

5457
boost::asio::ip::address m_address;
5558
};

‎libpoolprotocols/PoolURI.cpp

+31-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <network/uri/detail/decode.hpp>
55
#include <libpoolprotocols/PoolURI.h>
66

7+
#include <iostream>
8+
79
using namespace dev;
810

911
typedef struct {
@@ -25,11 +27,9 @@ static std::map<std::string, SchemeAttributes> s_schemes = {
2527
{"stratum+ssl", {ProtocolFamily::STRATUM, SecureLevel::TLS12, 0}},
2628
{"stratum1+ssl", {ProtocolFamily::STRATUM, SecureLevel::TLS12, 1}},
2729
{"stratum2+ssl", {ProtocolFamily::STRATUM, SecureLevel::TLS12, 2}},
28-
{"http", {ProtocolFamily::GETWORK, SecureLevel::NONE, 0}}
30+
{"http", {ProtocolFamily::GETWORK, SecureLevel::NONE, 0}}
2931
};
3032

31-
URI::URI() {}
32-
3333
URI::URI(const std::string uri)
3434
{
3535
std::string u = uri;
@@ -40,13 +40,17 @@ URI::URI(const std::string uri)
4040

4141
bool URI::KnownScheme()
4242
{
43+
if (!m_uri.scheme())
44+
return false;
4345
std::string s(*m_uri.scheme());
4446
boost::trim(s);
4547
return s_schemes.find(s) != s_schemes.end();
4648
}
4749

4850
ProtocolFamily URI::ProtoFamily() const
4951
{
52+
if (!m_uri.scheme())
53+
return ProtocolFamily::STRATUM;
5054
std::string s(*m_uri.scheme());
5155
s = network::detail::decode(s);
5256
boost::trim(s);
@@ -55,6 +59,8 @@ ProtocolFamily URI::ProtoFamily() const
5559

5660
unsigned URI::ProtoVersion() const
5761
{
62+
if (!m_uri.scheme())
63+
return 0;
5864
std::string s(*m_uri.scheme());
5965
s = network::detail::decode(s);
6066
boost::trim(s);
@@ -63,6 +69,8 @@ unsigned URI::ProtoVersion() const
6369

6470
SecureLevel URI::ProtoSecureLevel() const
6571
{
72+
if (!m_uri.scheme())
73+
return SecureLevel::NONE;
6674
std::string s(*m_uri.scheme());
6775
s = network::detail::decode(s);
6876
boost::trim(s);
@@ -81,6 +89,8 @@ std::string URI::KnownSchemes(ProtocolFamily family)
8189

8290
std::string URI::Scheme() const
8391
{
92+
if (!m_uri.scheme())
93+
return "";
8494
std::string s(*m_uri.scheme());
8595
s = network::detail::decode(s);
8696
boost::trim(s);
@@ -89,31 +99,41 @@ std::string URI::Scheme() const
8999

90100
std::string URI::Host() const
91101
{
102+
if (!m_uri.host())
103+
return "";
92104
std::string s(*m_uri.host());
93105
s = network::detail::decode(s);
94106
boost::trim(s);
95-
if (s == "--")
107+
return s;
108+
}
109+
110+
std::string URI::Path() const
111+
{
112+
if (!m_uri.path())
96113
return "";
114+
std::string s(*m_uri.path());
115+
s = network::detail::decode(s);
116+
boost::trim(s);
97117
return s;
98118
}
99119

100120
unsigned short URI::Port() const
101121
{
122+
if (!m_uri.port())
123+
return 0;
102124
std::string s(*m_uri.port());
103125
s = network::detail::decode(s);
104126
boost::trim(s);
105-
if (s == "--")
106-
return 0;
107127
return (unsigned short)atoi(s.c_str());
108128
}
109129

110130
std::string URI::User() const
111131
{
132+
if (!m_uri.user_info())
133+
return "";
112134
std::string s(*m_uri.user_info());
113135
s = network::detail::decode(s);
114136
boost::trim(s);
115-
if (s == "--")
116-
return "";
117137
size_t f = s.find(":");
118138
if (f == std::string::npos)
119139
return s;
@@ -122,13 +142,14 @@ std::string URI::User() const
122142

123143
std::string URI::Pswd() const
124144
{
145+
if (!m_uri.user_info())
146+
return "";
125147
std::string s(*m_uri.user_info());
126148
s = network::detail::decode(s);
127149
boost::trim(s);
128-
if (s == "--")
129-
return "";
130150
size_t f = s.find(":");
131151
if (f == std::string::npos)
132152
return "";
133153
return s.substr(f + 1);
134154
}
155+

‎libpoolprotocols/PoolURI.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ enum class ProtocolFamily {GETWORK = 0, STRATUM};
1313
class URI : network::uri
1414
{
1515
public:
16-
URI();
16+
URI() {};
1717
URI(const std::string uri);
1818

1919
std::string Scheme() const;
2020
std::string Host() const;
21+
std::string Path() const;
2122
unsigned short Port() const;
2223
std::string User() const;
2324
std::string Pswd() const;
@@ -30,7 +31,7 @@ class URI : network::uri
3031
static std::string KnownSchemes(ProtocolFamily family);
3132

3233
private:
33-
network::uri m_uri;
34+
network::uri m_uri;
3435
};
3536

3637
}

‎libpoolprotocols/getwork/EthGetworkClient.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ void EthGetworkClient::connect()
2424
if (m_connection_changed) {
2525
stringstream ss;
2626
ss << "http://" + m_conn.Host() << ':' << m_conn.Port();
27+
if (m_conn.Path().length())
28+
ss << m_conn.Path();
2729
p_client = new ::JsonrpcGetwork(new jsonrpc::HttpClient(ss.str()));
2830
}
2931

0 commit comments

Comments
 (0)
This repository has been archived.