class SelectionRule {

    public static boolean shouldWeAddThisBlock(
            BlockDifficulty blockDifficulty,
            BlockDifficulty currentDifficulty,
            Block block,
            Block currentBlock) {

        int compareDifficulties = blockDifficulty.compareTo(currentDifficulty);

        if (compareDifficulties > 0) {
            return true;
        }

        if (compareDifficulties < 0) {
            return false;
        }

        Coin pfm = currentBlock.getHeader().getPaidFees().multiply(PAID_FEES_MULTIPLIER_CRITERIA);
        // fees over PAID_FEES_MULTIPLIER_CRITERIA times higher
        if (block.getHeader().getPaidFees().compareTo(pfm) > 0) {
            return true;
        }

        Coin blockFeesCriteria = block.getHeader().getPaidFees().multiply(PAID_FEES_MULTIPLIER_CRITERIA);

        // As a last resort, choose the block with the lower hash. We ask that
        // the fees are at least bigger than the half of current block.
        return currentBlock.getHeader().getPaidFees().compareTo(blockFeesCriteria) < 0 &&
                isThisBlockHashSmaller(block.getHash().getBytes(), currentBlock.getHash().getBytes());
    }

}