Beispiel #1
0
  @Override
  public BigInteger getTotalDifficulty() {
    long maxNumber = getMaxNumber();

    List<BlockInfo> blockInfos = index.get((int) maxNumber);
    for (BlockInfo blockInfo : blockInfos) {
      if (blockInfo.isMainChain()) {
        return blockInfo.getCummDifficulty();
      }
    }

    while (true) {
      --maxNumber;
      List<BlockInfo> infos = getBlockInfoForLevel(maxNumber);

      for (BlockInfo blockInfo : infos) {
        if (blockInfo.isMainChain()) {
          return blockInfo.getCummDifficulty();
        }
      }
    }
  }