Esempio n. 1
0
static void search_for_extra_nonce(struct thr_info *thr, struct work *work,
                                   struct hf_candidate_nonce *n)
{
    uint32_t nonce = n->nonce;
    int i;

    /* No function to test with ntime offsets yet */
    if (n->ntime & HF_NTIME_MASK)
        return;
    for (i = 0; i < 128; i++, nonce++) {
        /* We could break out of this early if nonce wraps or if we
         * find one correct nonce since the chance of more is extremely
         * low but this function will be hit so infrequently we may as
         * well test the entire range with the least code. */
        if (test_nonce(work, nonce))
            submit_tested_work(thr, work);
    }
}
Esempio n. 2
0
static void gridseed_test_btc_nonce(struct cgpu_info *gridseed, GRIDSEED_INFO *info,
		struct thr_info *thr, unsigned char *data)
{
	struct work *work;
	uint32_t nonce;
	int workid, index, i;
	bool valid = false;
	bool nowork = false;

	memcpy(&workid, data+8, 4);
	memcpy(&nonce, data+4, 4);
	nonce = htole32(nonce);

	mutex_lock(&info->qlock);
	nowork = (info->soft_queue_len <= 0);
	for(i=0; i<info->soft_queue_len; i++) {
		struct work *dupwork;
		work = info->workqueue[i];
		if (work->devflag == false)
			continue;
		if (work->id > workid)
			break;
		dupwork = copy_work(work);
		if (dupwork == NULL)
			continue;
		if (test_nonce(dupwork, nonce)) {
			submit_tested_work(thr, dupwork);
			index = i;
			valid = true;
			free_work(dupwork);
			break;
		} else
			free_work(dupwork);
	}
	if (valid)
		__gridseed_purge_work_queue(gridseed, info, index);
	mutex_unlock(&info->qlock);

	if (!valid && !nowork)
		inc_hw_errors(thr);
	return;
}