示例#1
0
        id_ = job_id + hex_nonce
        self.submits[id_] = time() #'id': id_,
        return self.send_message({'params': [self.url.username, job_id, extranonce2, ntime, hex_nonce], 'id': id_, 'method': u'mining.submit'})

    def handleWork(self, (work, extranonce2, job_id), pushed=False):
        if work is None:
            return;

        aw = AssignedWork()
        aw.data = work['data'].decode('hex')[:80] #should be 80 anyhow, but we leave it
        aw.target = work['target'].decode('hex')
        aw.mask = work.get('mask', 32) #TODO direct
        aw.setMaxTimeIncrement(self.maxtime) #This might be really important, somehow... Figure out the best setting!
        aw.identifier = work.get('identifier', aw.data[4:36]) #Wait what is this??
        aw.extranonce2 = extranonce2
        aw.job_id = job_id
        
        if pushed:
            self.runCallback('push', aw)
        self.runCallback('work', aw)

    def _failure(self):
        if self.saidConnected:
            self.saidConnected = False
            self.runCallback('disconnect')
            if self.socket_handler:
                self.socket_handler.close_when_done() #thread should stop when done?
            self.connect() #Try once more
        else:
            self.runCallback('failure')
        
示例#2
0
    def handleWork(self, (work, extranonce2, job_id), pushed=False):
        if work is None:
            return

        aw = AssignedWork()
        aw.data = work['data'].decode(
            'hex')[:80]  #should be 80 anyhow, but we leave it
        aw.target = work['target'].decode('hex')
        aw.mask = work.get('mask', 32)  #TODO direct
        aw.setMaxTimeIncrement(
            self.maxtime
        )  #This might be really important, somehow... Figure out the best setting!
        aw.identifier = work.get('identifier',
                                 aw.data[4:36])  #Wait what is this??
        aw.extranonce2 = extranonce2
        aw.job_id = job_id

        if pushed:
            self.runCallback('push', aw)
        self.runCallback('work', aw)

    def _failure(self):
        if self.saidConnected:
            self.saidConnected = False
            self.runCallback('disconnect')
            if self.socket_handler:
                self.socket_handler.close_when_done(
                )  #thread should stop when done?
            self.connect()  #Try once more
        else:
            self.runCallback('failure')