|
|
@ -170,6 +170,7 @@ static pthread_mutex_t *stgd_lock; |
|
|
|
pthread_mutex_t console_lock; |
|
|
|
pthread_mutex_t console_lock; |
|
|
|
pthread_mutex_t ch_lock; |
|
|
|
pthread_mutex_t ch_lock; |
|
|
|
static pthread_rwlock_t blk_lock; |
|
|
|
static pthread_rwlock_t blk_lock; |
|
|
|
|
|
|
|
static pthread_mutex_t sshare_lock; |
|
|
|
|
|
|
|
|
|
|
|
pthread_rwlock_t netacc_lock; |
|
|
|
pthread_rwlock_t netacc_lock; |
|
|
|
|
|
|
|
|
|
|
@ -225,6 +226,21 @@ struct block { |
|
|
|
|
|
|
|
|
|
|
|
static struct block *blocks = NULL; |
|
|
|
static struct block *blocks = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int swork_id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* For creating a hash database of stratum shares submitted that have not had
|
|
|
|
|
|
|
|
* a response yet */ |
|
|
|
|
|
|
|
struct stratum_share { |
|
|
|
|
|
|
|
struct pool *pool; |
|
|
|
|
|
|
|
char hash6[8]; |
|
|
|
|
|
|
|
UT_hash_handle hh; |
|
|
|
|
|
|
|
bool block; |
|
|
|
|
|
|
|
int id; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct stratum_share *stratum_shares = NULL; |
|
|
|
|
|
|
|
|
|
|
|
char *opt_socks_proxy = NULL; |
|
|
|
char *opt_socks_proxy = NULL; |
|
|
|
|
|
|
|
|
|
|
|
static const char def_conf[] = "cgminer.conf"; |
|
|
|
static const char def_conf[] = "cgminer.conf"; |
|
|
@ -2712,6 +2728,28 @@ static void *submit_work_thread(void *userdata) |
|
|
|
work->stale = true; |
|
|
|
work->stale = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (work->stratum) { |
|
|
|
|
|
|
|
struct stratum_share *sshare = calloc(sizeof(struct stratum_share), 1); |
|
|
|
|
|
|
|
uint32_t *hash32 = (uint32_t *)work->hash; |
|
|
|
|
|
|
|
char *s = alloca(1024); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(sshare->hash6, "%08lx", (unsigned long)hash32[6]); |
|
|
|
|
|
|
|
sshare->block = work->block; |
|
|
|
|
|
|
|
sshare->pool = pool; |
|
|
|
|
|
|
|
/* Give the stratum share a unique id */ |
|
|
|
|
|
|
|
mutex_lock(&sshare_lock); |
|
|
|
|
|
|
|
sshare->id = swork_id++; |
|
|
|
|
|
|
|
HASH_ADD_INT(stratum_shares, id, sshare); |
|
|
|
|
|
|
|
mutex_unlock(&sshare_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(s, "{\"params\": [\"%s\", \"%s\", \"%s\", \"%s\", \"%08lx\"], \"id\": %d, \"method\": \"mining.submit\"}", |
|
|
|
|
|
|
|
pool->rpc_user, work->job_id, work->nonce2, work->ntime, (unsigned long)work->blk.nonce, sshare->id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sock_send(pool->sock, s, strlen(s)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
goto out; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ce = pop_curl_entry(pool); |
|
|
|
ce = pop_curl_entry(pool); |
|
|
|
/* submit solution to bitcoin via JSON-RPC */ |
|
|
|
/* submit solution to bitcoin via JSON-RPC */ |
|
|
|
while (!submit_upstream_work(work, ce->curl, resubmit)) { |
|
|
|
while (!submit_upstream_work(work, ce->curl, resubmit)) { |
|
|
@ -5650,6 +5688,7 @@ int main(int argc, char *argv[]) |
|
|
|
mutex_init(&control_lock); |
|
|
|
mutex_init(&control_lock); |
|
|
|
mutex_init(&sharelog_lock); |
|
|
|
mutex_init(&sharelog_lock); |
|
|
|
mutex_init(&ch_lock); |
|
|
|
mutex_init(&ch_lock); |
|
|
|
|
|
|
|
mutex_init(&sshare_lock); |
|
|
|
rwlock_init(&blk_lock); |
|
|
|
rwlock_init(&blk_lock); |
|
|
|
rwlock_init(&netacc_lock); |
|
|
|
rwlock_init(&netacc_lock); |
|
|
|
|
|
|
|
|
|
|
|