@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
ScanHash sh = new ScanHash();
Config config = null;
int accepted = 0, rejected = 0;
try {
config = Config.getConfig();
long targetTotalTime = config.getTargetTotalTime();
log.info("Start " + config.getUsername() + " [" + config.getAuth()
+ "]");
long startTime = System.currentTimeMillis();
do {
long startRoundTime = System.currentTimeMillis();
Work work = fetchWork(config);
boolean found = sh.scan(work, 1, config.getScanCount());
if (found) {
log.warning("found: " + work.data);
if (submitWork(config, work)) {
log.warning("Yay! Accepted!");
accepted++;
} else {
log.warning("Doh! Rejected!");
rejected++;
}
} else {
adjustHashPerRound(config, startRoundTime);
}
} while (timePassed(startTime) < targetTotalTime);
log.info("Times Up!");
} catch (DeadlineExceededException dee) {
log.info("DealineExcessedException!");
} catch (Exception ex) {
log.severe("Exception Caught! " + ex);
ex.printStackTrace(System.err);
} finally {
log.info("Fin. H=" + sh.getCount() + ", A=" + accepted + ", R="
+ rejected);
}
config.save();
resp.getWriter().println(
"Fin. H=" + sh.getCount() + ", A=" + accepted + ", R="
+ rejected);
}