mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-29 16:04:33 +00:00
Merge branch 'kano' of https://github.com/kanoi/cgminer into kanoi
This commit is contained in:
commit
11e5d2eadd
46
main.c
46
main.c
@ -260,14 +260,6 @@ static int total_getworks, total_stale, total_discarded;
|
|||||||
static int total_queued;
|
static int total_queued;
|
||||||
static unsigned int new_blocks;
|
static unsigned int new_blocks;
|
||||||
|
|
||||||
enum block_change {
|
|
||||||
BLOCK_NONE,
|
|
||||||
BLOCK_LP,
|
|
||||||
BLOCK_DETECT,
|
|
||||||
BLOCK_FIRST,
|
|
||||||
};
|
|
||||||
|
|
||||||
static enum block_change block_changed = BLOCK_FIRST;
|
|
||||||
static unsigned int local_work;
|
static unsigned int local_work;
|
||||||
static unsigned int total_go, total_ro;
|
static unsigned int total_go, total_ro;
|
||||||
|
|
||||||
@ -2690,7 +2682,7 @@ static void set_curblock(char *hexstr, unsigned char *hash)
|
|||||||
free(old_hash);
|
free(old_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_work_current(struct work *work)
|
static void test_work_current(struct work *work, bool longpoll)
|
||||||
{
|
{
|
||||||
struct block *s;
|
struct block *s;
|
||||||
char *hexstr;
|
char *hexstr;
|
||||||
@ -2715,19 +2707,18 @@ static void test_work_current(struct work *work)
|
|||||||
HASH_ADD_STR(blocks, hash, s);
|
HASH_ADD_STR(blocks, hash, s);
|
||||||
wr_unlock(&blk_lock);
|
wr_unlock(&blk_lock);
|
||||||
set_curblock(hexstr, work->data);
|
set_curblock(hexstr, work->data);
|
||||||
|
if (++new_blocks == 1)
|
||||||
|
goto out_free;
|
||||||
|
|
||||||
new_blocks++;
|
if (longpoll)
|
||||||
if (block_changed != BLOCK_LP && block_changed != BLOCK_FIRST) {
|
applog(LOG_NOTICE, "LONGPOLL detected new block on network, waiting on fresh work");
|
||||||
block_changed = BLOCK_DETECT;
|
else if (have_longpoll)
|
||||||
if (have_longpoll)
|
applog(LOG_NOTICE, "New block detected on network before longpoll, waiting on fresh work");
|
||||||
applog(LOG_NOTICE, "New block detected on network before longpoll, waiting on fresh work");
|
else
|
||||||
else
|
applog(LOG_NOTICE, "New block detected on network, waiting on fresh work");
|
||||||
applog(LOG_NOTICE, "New block detected on network, waiting on fresh work");
|
|
||||||
} else
|
|
||||||
block_changed = BLOCK_NONE;
|
|
||||||
restart_threads();
|
restart_threads();
|
||||||
}
|
}
|
||||||
|
out_free:
|
||||||
free(hexstr);
|
free(hexstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2773,7 +2764,7 @@ static void *stage_thread(void *userdata)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_work_current(work);
|
test_work_current(work, false);
|
||||||
|
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
applog(LOG_DEBUG, "Pushing work to getwork queue");
|
applog(LOG_DEBUG, "Pushing work to getwork queue");
|
||||||
@ -4399,8 +4390,9 @@ static void convert_to_work(json_t *val, bool rolltime)
|
|||||||
work->rolltime = rolltime;
|
work->rolltime = rolltime;
|
||||||
/* We'll be checking this work item twice, but we already know it's
|
/* We'll be checking this work item twice, but we already know it's
|
||||||
* from a new block so explicitly force the new block detection now
|
* from a new block so explicitly force the new block detection now
|
||||||
* rather than waiting for it to hit the stage thread */
|
* rather than waiting for it to hit the stage thread. This also
|
||||||
test_work_current(work);
|
* allows testwork to know whether LP discovered the block or not. */
|
||||||
|
test_work_current(work, true);
|
||||||
|
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
applog(LOG_DEBUG, "Pushing converted work to stage thread");
|
applog(LOG_DEBUG, "Pushing converted work to stage thread");
|
||||||
@ -4467,16 +4459,6 @@ static void *longpoll_thread(void *userdata)
|
|||||||
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
|
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
|
||||||
false, true, &rolltime, pool);
|
false, true, &rolltime, pool);
|
||||||
if (likely(val)) {
|
if (likely(val)) {
|
||||||
/* Keep track of who ordered a restart_threads to make
|
|
||||||
* sure it's only done once per new block */
|
|
||||||
if (block_changed != BLOCK_DETECT) {
|
|
||||||
block_changed = BLOCK_LP;
|
|
||||||
applog(LOG_NOTICE, "LONGPOLL detected new block on network, waiting on fresh work");
|
|
||||||
} else {
|
|
||||||
applog(LOG_INFO, "LONGPOLL received after new block already detected");
|
|
||||||
block_changed = BLOCK_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
convert_to_work(val, rolltime);
|
convert_to_work(val, rolltime);
|
||||||
failures = 0;
|
failures = 0;
|
||||||
json_decref(val);
|
json_decref(val);
|
||||||
|
1
miner.h
1
miner.h
@ -314,6 +314,7 @@ extern char *opt_kernel_path;
|
|||||||
extern char *cgminer_path;
|
extern char *cgminer_path;
|
||||||
extern bool opt_autofan;
|
extern bool opt_autofan;
|
||||||
extern bool opt_autoengine;
|
extern bool opt_autoengine;
|
||||||
|
extern bool use_curses;
|
||||||
|
|
||||||
extern const uint32_t sha256_init_state[];
|
extern const uint32_t sha256_init_state[];
|
||||||
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user