Browse Source

Bugfix: Enforce --expiry, but split --expiry-lp for a longer expiry on longpoll setups

Luke Dashjr 13 years ago
parent
commit
32032d18d9
2 changed files with 12 additions and 3 deletions
  1. 2 1
      README
  2. 10 2
      miner.c

+ 2 - 1
README

@@ -138,7 +138,8 @@ Options for both config file and command line:
 --coinbase-sig <arg> Set coinbase signature when possible
 --debug|-D          Enable debug output
 --debuglog          Enable debug logging
---expiry|-E <arg>   Upper bound on how many seconds after getting work we consider a share from it stale (default: 120)
+--expiry|-E <arg>   Upper bound on how many seconds after getting work we consider a share from it stale (w/o longpoll active) (default: 120)
+--expiry-lp <arg>   Upper bound on how many seconds after getting work we consider a share from it stale (with longpoll active) (default: 3600)
 --failover-only     Don't leak work to backup pools when primary pool is lagging
 --kernel-path|-K <arg> Specify a path to where bitstream and kernel files are (default: "/usr/local/bin")
 --load-balance      Change multipool strategy from failover to efficiency based balance

+ 10 - 2
miner.c

@@ -125,6 +125,7 @@ int opt_log_interval = 5;
 int opt_queue = 1;
 int opt_scantime = 60;
 int opt_expiry = 120;
+int opt_expiry_lp = 3600;
 int opt_bench_algo = -1;
 static const bool opt_time = true;
 unsigned long long global_hashrate;
@@ -1063,7 +1064,10 @@ static struct opt_table opt_config_table[] = {
 #endif
 	OPT_WITH_ARG("--expiry|-E",
 		     set_int_0_to_9999, opt_show_intval, &opt_expiry,
-		     "Upper bound on how many seconds after getting work we consider a share from it stale"),
+		     "Upper bound on how many seconds after getting work we consider a share from it stale (w/o longpoll active)"),
+	OPT_WITH_ARG("--expiry-lp",
+		     set_int_0_to_9999, opt_show_intval, &opt_expiry_lp,
+		     "Upper bound on how many seconds after getting work we consider a share from it stale (with longpoll active)"),
 	OPT_WITHOUT_ARG("--failover-only",
 			opt_set_bool, &opt_fail_only,
 			"Don't leak work to backup pools when primary pool is lagging"),
@@ -3209,11 +3213,15 @@ static bool stale_work(struct work *work, bool share)
 	/* Technically the rolltime should be correct but some pools
 	 * advertise a broken expire= that is lower than a meaningful
 	 * scantime */
-	if (work->rolltime > opt_scantime)
+	if (work->rolltime >= opt_scantime)
 		work_expiry = work->rolltime;
 	else
 		work_expiry = opt_expiry;
 
+	int max_expiry = (have_longpoll ? opt_expiry_lp : opt_expiry);
+	if (work_expiry > max_expiry)
+		work_expiry = max_expiry;
+
 	if (share) {
 		/* If the share isn't on this pool's latest block, it's stale */
 		if (pool->block_id && pool->block_id != block_id)