Merge pull request #266 from Fredyy90/NScrypt

added IP to invalid "job id" log entry
This commit is contained in:
ahmedbodi 2014-02-19 15:27:55 +00:00
commit 12fa1a4e97
2 changed files with 9 additions and 5 deletions

View File

@ -159,12 +159,16 @@ class TemplateRegistry(object):
return diff1 / difficulty return diff1 / difficulty
def get_job(self, job_id): def get_job(self, job_id, worker_name, ip=False):
'''For given job_id returns BlockTemplate instance or None''' '''For given job_id returns BlockTemplate instance or None'''
try: try:
j = self.jobs[job_id] j = self.jobs[job_id]
except: except:
log.info("Job id '%s' not found" % job_id) log.info("Job id '%s' not found, worker_name: '%s'" % (job_id, worker_name))
if ip:
log.info("Worker submited invalid Job id: IP %s", str(ip))
return None return None
# Now we have to check if job is still valid. # Now we have to check if job is still valid.
@ -181,7 +185,7 @@ class TemplateRegistry(object):
return j return j
def submit_share(self, job_id, worker_name, session, extranonce1_bin, extranonce2, ntime, nonce, def submit_share(self, job_id, worker_name, session, extranonce1_bin, extranonce2, ntime, nonce,
difficulty): difficulty, ip=False):
'''Check parameters and finalize block template. If it leads '''Check parameters and finalize block template. If it leads
to valid block candidate, asynchronously submits the block to valid block candidate, asynchronously submits the block
back to the bitcoin network. back to the bitcoin network.
@ -197,7 +201,7 @@ class TemplateRegistry(object):
raise SubmitException("Incorrect size of extranonce2. Expected %d chars" % (self.extranonce2_size*2)) raise SubmitException("Incorrect size of extranonce2. Expected %d chars" % (self.extranonce2_size*2))
# Check for job # Check for job
job = self.get_job(job_id) job = self.get_job(job_id, worker_name, ip)
if job == None: if job == None:
raise SubmitException("Job '%s' not found" % job_id) raise SubmitException("Job '%s' not found" % job_id)

View File

@ -169,7 +169,7 @@ class MiningService(GenericService):
# and it is valid proof of work. # and it is valid proof of work.
try: try:
(block_header, block_hash, share_diff, on_submit) = Interfaces.template_registry.submit_share(job_id, (block_header, block_hash, share_diff, on_submit) = Interfaces.template_registry.submit_share(job_id,
worker_name, session, extranonce1_bin, extranonce2, ntime, nonce, difficulty) worker_name, session, extranonce1_bin, extranonce2, ntime, nonce, difficulty, ip)
except SubmitException as e: except SubmitException as e:
# block_header and block_hash are None when submitted data are corrupted # block_header and block_hash are None when submitted data are corrupted
invalid += 1 invalid += 1