public void mineBlock(Block b) {
   for (int nonce = Integer.MIN_VALUE; nonce <= Integer.MAX_VALUE; ++nonce) {
     b.setNonce(nonce);
     b.computeHash();
     BigInteger hashAsInteger = new Hash(b.getHash()).toBigInteger();
     if (hashAsInteger.compareTo(Difficulty.getTarget(b.getDifficultyTarget())) <= 0) {
       break;
     }
   }
 }
 public Block createBlock(String previous, Transaction coinbase) {
   Block block = new Block();
   try {
     Thread.sleep(1001);
   } catch (InterruptedException e) {
   }
   block.setCreateTime(System.currentTimeMillis() / 1000);
   block.setDifficultyTarget(chain.getGenesis().getDifficultyTarget());
   block.setPreviousHash(previous);
   block.setVersion(2);
   block.setNonce(0);
   block.setTransactions(new ArrayList<Transaction>());
   block.getTransactions().add(coinbase);
   return block;
 }