8000 Custom username and password for pool · coderlv/stratum-mining-proxy@268a1f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 268a1f2

Browse files
committed
Custom username and password for pool
1 parent e191748 commit 268a1f2

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

mining_libs/stratum_listener.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ class StratumProxyService(GenericService):
8080
service_vendor = 'mining_proxy'
8181
is_default = True
8282

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+
8391
_f = None # Factory of upstream Stratum connection
8492
extranonce1 = None
8593
extranonce2_size = None
@@ -130,7 +138,11 @@ def _drop_tail(self, result, tail):
130138
def authorize(self, worker_name, worker_password, *args):
131139
if self._f.client == None or not self._f.client.connected:
132140
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+
134146
result = (yield self._f.rpc('mining.authorize', [worker_name, worker_password]))
135147
defer.returnValue(result)
136148

@@ -163,7 +175,12 @@ def subscribe(self, *args):
163175
def submit(self, worker_name, job_id, extranonce2, ntime, nonce, *args):
164176
if self._f.client == None or not self._f.client.connected:
165177
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+
167184
session = self.connection_ref().get_session()
168185
tail = session.get('tail')
169186
if tail == None:
@@ -172,7 +189,7 @@ def submit(self, worker_name, job_id, extranonce2, ntime, nonce, *args):
172189
start = time.time()
173190

174191
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]))
176193
except RemoteServiceException as exc:
177194
response_time = (time.time() - start) * 1000
178195
log.info("[%dms] Share from '%s' REJECTED: %s" % (response_time, worker_name, str(exc)))

mining_proxy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def on_connect(f, workers, job_registry):
107107
(_, extranonce1, extranonce2_size) = (yield f.rpc('mining.subscribe', []))[:3]
108108
job_registry.set_extranonce(extranonce1, extranonce2_size)
109109
stratum_listener.StratumProxyService._set_extranonce(extranonce1, extranonce2_size)
110+
if args.custom_user:
111+
stratum_listener.StratumProxyService._set_custom_user(args.custom_user, args.custom_password)
110112

111113
defer.returnValue(f)
112114

0 commit comments

Comments
 (0)
0