Coverage Summary for Class: BlockChainStatus (co.rsk.core.bc)

Class Class, % Method, % Line, %
BlockChainStatus 100% (1/1) 60% (3/5) 75% (6/8)


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2017 RSK Labs Ltd. 4  * 5  * This program is free software: you can redistribute it and/or modify 6  * it under the terms of the GNU Lesser General Public License as published by 7  * the Free Software Foundation, either version 3 of the License, or 8  * (at your option) any later version. 9  * 10  * This program is distributed in the hope that it will be useful, 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13  * GNU Lesser General Public License for more details. 14  * 15  * You should have received a copy of the GNU Lesser General Public License 16  * along with this program. If not, see <http://www.gnu.org/licenses/>. 17  */ 18  19 package co.rsk.core.bc; 20  21 import co.rsk.core.BlockDifficulty; 22 import co.rsk.net.Status; 23 import org.ethereum.core.Block; 24  25 /** 26  * Created by ajlopez on 29/07/2016. 27  */ 28  29 public class BlockChainStatus { 30  private final Block bestBlock; 31  private final BlockDifficulty totalDifficulty; 32  33  public BlockChainStatus(Block bestBlock, BlockDifficulty totalDifficulty) { 34  this.bestBlock = bestBlock; 35  this.totalDifficulty = totalDifficulty; 36  } 37  38  public Block getBestBlock() { 39  return bestBlock; 40  } 41  42  public long getBestBlockNumber() { 43  return bestBlock.getNumber(); 44  } 45  46  public BlockDifficulty getTotalDifficulty() { 47  return totalDifficulty; 48  } 49  50  public boolean hasLowerTotalDifficultyThan(Status status) { 51  return this.totalDifficulty.compareTo(status.getTotalDifficulty()) < 0; 52  } 53 }