Exemplo n.º 1
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;
}
Exemplo n.º 2
0
void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res)
{
	struct pc_data *pcd = malloc(sizeof(struct pc_data));
	int buffersize;

	if (unlikely(!pcd)) {
		applog(LOG_ERR, "Failed to malloc pc_data in postcalc_hash_async");
		return;
	}

	pcd->thr = thr;
	pcd->work = copy_work(work);
	buffersize = BUFFERSIZE;

	memcpy(&pcd->res, res, buffersize);

	if (pthread_create(&pcd->pth, NULL, postcalc_hash, (void *)pcd)) {
		applog(LOG_ERR, "Failed to create postcalc_hash thread");
		return;
	}
}