@@ -80,6 +80,14 @@ class StratumProxyService(GenericService):
80
80
service_vendor = 'mining_proxy'
81
81
is_default = True
82
82
83
+ custom_user = None
84
+ custom_password = None
85
+
86
+ @classmethod
87
+ def _set_custom_user (cls , custom_user , custom_password ):
88
+ cls .custom_user = custom_user
89
+ cls .custom_password = custom_password
90
+
83
91
_f = None # Factory of upstream Stratum connection
84
92
extranonce1 = None
85
93
extranonce2_size = None
@@ -130,7 +138,11 @@ def _drop_tail(self, result, tail):
130
138
def authorize (self , worker_name , worker_password , * args ):
131
139
if self ._f .client == None or not self ._f .client .connected :
132
140
yield self ._f .on_connect
133
-
141
+
142
+ if self .custom_user :
143
+ worker_name = self .custom_user
144
+ worker_password = self .custom_password
145
+
134
146
result = (yield self ._f .rpc ('mining.authorize' , [worker_name , worker_password ]))
135
147
defer .returnValue (result )
136
148
@@ -163,7 +175,12 @@ def subscribe(self, *args):
163
175
def submit (self , worker_name , job_id , extranonce2 , ntime , nonce , * args ):
164
176
if self ._f .client == None or not self ._f .client .connected :
165
177
raise SubmitException ("Upstream not connected" )
166
-
178
+
179
+ if self .custom_user :
180
+ remote_name = self .custom_user
181
+ else :
182
+ remote_name = worker_name
183
+
167
184
session = self .connection_ref ().get_session ()
168
185
tail = session .get ('tail' )
169
186
if tail == None :
@@ -172,7 +189,7 @@ def submit(self, worker_name, job_id, extranonce2, ntime, nonce, *args):
172
189
start = time .time ()
173
190
174
191
try :
175
- result = (yield self ._f .rpc ('mining.submit' , [worker_name , job_id , tail + extranonce2 , ntime , nonce ]))
192
+ result = (yield self ._f .rpc ('mining.submit' , [remote_name , job_id , tail + extranonce2 , ntime , nonce ]))
176
193
except RemoteServiceException as exc :
177
194
response_time = (time .time () - start ) * 1000
178
195
log .info ("[%dms] Share from '%s' REJECTED: %s" % (response_time , worker_name , str (exc )))
0 commit comments