@Override
 public void run() {
   String shareRequest =
       plotFile.getAddress()
           + ":"
           + nonce
           + ":"
           + processing.getHeight()
           + " deadline {"
           + deadline
           + "}";
   LOGGER.info("Submitting share {" + shareRequest + "}");
   try {
     if (poolType.equals(POOL_TYPE_URAY)) {
       String request =
           poolUrl
               + "/burst?requestType=submitNonce&secretPhrase=pool-mining&nonce="
               + Convert.toUnsignedLong(nonce)
               + "&accountId="
               + Convert.toUnsignedLong(plotFile.getAddress());
       String response = restTemplate.postForObject(request, shareRequest, String.class);
       LOGGER.info("Response {" + response + "}}");
       plotFile.addShare();
     } else if (poolType.equals(POOL_TYPE_OFFICIAL)) {
       shareRequest = plotFile.getAddress() + ":" + nonce + ":" + processing.getHeight() + "\n";
       String response =
           restTemplate.postForObject(poolUrl + "/pool/submitWork", shareRequest, String.class);
       LOGGER.info("Response {" + response + "}}");
       plotFile.addShare();
     }
     lastShareSubmitTime = System.currentTimeMillis();
   } catch (Exception ex) {
     LOGGER.info("Failed to submitShare {" + shareRequest + "}");
   }
 }
    private void checkChunkPoolUray(byte[] chunk, long chunk_start_nonce) {
      Shabal256 md = new Shabal256();
      BigInteger lowest =
          new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16);
      long lowestscoop = 0;
      for (long i = 0; i < plotFile.getStaggeramt(); i++) {
        md.reset();
        md.update(processing.getGensig());
        md.update(chunk, (int) (i * MiningPlot.SCOOP_SIZE), MiningPlot.SCOOP_SIZE);
        byte[] hash = md.digest();
        BigInteger num =
            new BigInteger(
                1,
                new byte[] {
                  hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]
                });
        BigInteger deadline = num.divide(BigInteger.valueOf(processing.getBaseTargetL()));

        int compare = deadline.compareTo(lowest);
        if (compare < 0) {
          lowest = deadline;
          lowestscoop = chunk_start_nonce + i;
        }
        if (!running) return;
      }
      registerBestShareForChunk(lowest, lowestscoop, plotFile);
    }
    private void checkChunkPoolOfficial(byte[] chunk, long chunk_start_nonce) {
      Shabal256 md = new Shabal256();
      for (long i = 0; i < plotFile.getStaggeramt(); i++) {
        md.reset();
        md.update(processing.getGensig());
        md.update(chunk, (int) (i * MiningPlot.SCOOP_SIZE), MiningPlot.SCOOP_SIZE);
        byte[] hash = md.digest();
        BigInteger num =
            new BigInteger(
                1,
                new byte[] {
                  hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]
                });
        BigInteger deadline = num.divide(BigInteger.valueOf(processing.getBaseTargetL()));
        int compare = deadline.compareTo(BigInteger.valueOf(processing.getTargetDeadlineL()));

        if (compare <= 0) {
          shareExecutor.execute(new SubmitShare(chunk_start_nonce + i, plotFile, deadline));
        }
        if (!running) return;
      }
    }
    @Override
    public void run() {

      try (RandomAccessFile f = new RandomAccessFile(plotFile.getPlotFile(), "r")) {
        long chunks = plotFile.getPlots() / plotFile.getStaggeramt();
        for (long i = 0; i < chunks; i++) {
          f.seek(
              (i * plotFile.getStaggeramt() * MiningPlot.PLOT_SIZE)
                  + (scoopnum * plotFile.getStaggeramt() * MiningPlot.SCOOP_SIZE));
          byte[] chunk = new byte[(int) (plotFile.getStaggeramt() * MiningPlot.SCOOP_SIZE)];
          f.readFully(chunk);
          if (poolType.equals(POOL_TYPE_URAY)) {
            checkChunkPoolUray(chunk, plotFile.getStartnonce() + (i * plotFile.getStaggeramt()));
          } else if (poolType.equals(POOL_TYPE_OFFICIAL)) {
            checkChunkPoolOfficial(
                chunk, plotFile.getStartnonce() + (i * plotFile.getStaggeramt()));
          }
          if (!running) return;
        }
      } catch (FileNotFoundException e) {
        LOGGER.info("Cannot open file: " + plotFile.getPlotFile().getName());
        e.printStackTrace();
      } catch (IOException e) {
        LOGGER.info("Error reading file: " + plotFile.getPlotFile().getName());
      }

      LOGGER.info("Finished mining {" + plotFile.getUUID() + "}");
      plotFile.addChecked();
      minerThreads.remove(this);
    }