Package net.sdiz.bitcoin.jdo

Examples of net.sdiz.bitcoin.jdo.Config


  @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);
  }
View Full Code Here

TOP

Related Classes of net.sdiz.bitcoin.jdo.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.