Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'work_expire_enhancements' of git://gitorious.org/~Luke-…

…Jr/bitcoin/luke-jrs-pushpool into tmp
  • Loading branch information...
commit 646bfa30fb1ae53568af3f27555ae2068888cf00 2 parents 7d58aae + 16352e8
Jeff Garzik authored Jeff Garzik committed
Showing with 18 additions and 7 deletions.
  1. +10 −1 config.c
  2. +3 −0  example-cfg.json
  3. +1 −5 msg.c
  4. +2 −1  server.c
  5. +2 −0  server.h
View
11 config.c
@@ -303,7 +303,7 @@ static void parse_database(const json_t *db_obj)
void read_config(void)
{
- json_t *jcfg, *cred_expire;
+ json_t *jcfg, *cred_expire, *tmp_json;
json_error_t err;
const char *tmp_str, *rpcuser, *rpcpass;
char *file_data;
@@ -393,6 +393,10 @@ void read_config(void)
if (json_is_true(json_object_get(jcfg, "rpc.target.rewrite")))
srv.easy_target = json_string(EASY_TARGET);
+ tmp_json = json_object_get(jcfg, "work.expire");
+ if (json_is_integer(tmp_json))
+ srv.work_expire = json_integer_value(tmp_json);
+
if (!srv.pid_file) {
if (!(srv.pid_file = strdup("/var/run/pushpoold.pid"))) {
applog(LOG_ERR, "no core");
@@ -402,6 +406,11 @@ void read_config(void)
if (json_is_true(json_object_get(jcfg, "roll.ntime.disable")))
srv.disable_roll_ntime = true;
+ else
+ if (asprintf(&srv.work_expire_str, "expire=%d", srv.work_expire) < 0) {
+ applog(LOG_ERR, "OOM");
+ exit(1);
+ }
json_decref(jcfg);
}
View
3  example-cfg.json
@@ -87,6 +87,9 @@
# rewrite returned 'target' to difficulty-1?
"rpc.target.rewrite" : true,
+ # how long before work expires?
+ "work.expire" : 120,
+
# allow clients to update the ntime field of their work
"roll.ntime.disable" : false
}
View
6 msg.c
@@ -46,10 +46,6 @@ struct work_ent {
struct elist_head srv_log_node;
};
-enum {
- WORK_EXPIRE_INT = 120, /* expire older than X secs */
-};
-
static const char *bc_err_str[] = {
[BC_ERR_NONE] = "no error (success)",
[BC_ERR_INVALID] = "invalid parameter",
@@ -138,7 +134,7 @@ static void worker_log(const char *username, const unsigned char *data)
elist_add_tail(&ent->log_node, &worker->log);
elist_add_tail(&ent->srv_log_node, &srv.work_log);
- worker_log_expire(now - WORK_EXPIRE_INT);
+ worker_log_expire(now - srv.work_expire);
}
static const char *work_in_log(const char *username, const unsigned char *data)
View
3  server.c
@@ -108,6 +108,7 @@ struct server srv = {
.db_port = -1,
.cred_expire = 75,
+ .work_expire = 120,
};
static error_t parse_opt (int key, char *arg, struct argp_state *state)
@@ -779,7 +780,7 @@ static void http_handle_req(struct evhttp_request *req, bool longpoll)
if (!longpoll && !srv.disable_lp)
evhttp_add_header(req->output_headers, "X-Long-Polling", "/LP");
if (!srv.disable_roll_ntime)
- evhttp_add_header(req->output_headers, "X-Roll-NTime", "Y");
+ evhttp_add_header(req->output_headers, "X-Roll-NTime", srv.work_expire_str);
evhttp_send_reply(req, HTTP_OK, "ok", evbuf);
evbuffer_free(evbuf);
View
2  server.h
@@ -179,6 +179,8 @@ struct server {
struct htab *workers;
struct elist_head work_log;
+ unsigned int work_expire;
+ char *work_expire_str;
unsigned int cred_expire;

1 comment on commit 646bfa3

@ckolivas

So the mining software that till now has been checking for X-Roll-NTime: Y will break. Why is this a good idea?

Please sign in to comment.
Something went wrong with that request. Please try again.