src/main/java/toy/blockchain/Blockchain.java
/**
     * Check if a block was proposed by a leader that proposed one of the last f+1 blocks.
     * @param b block to be validated
     * @param f an upper bound on the faulty nodes number
     * @return true if the block proposer did not proposed one of the last f+1 blocks, false either
     */
Check if a block was proposed by a leader that proposed one of the last f+1 blocks.
@param b block to be validated
@param f an upper bound on the faulty nodes number
@return true if the block proposer did not proposed one of the last f+1 blocks, false either
Check if a block was proposed by a leader that proposed one of the last f + 1 blocks . @param b block to be validated @param f an upper bound on the faulty nodes number @return true if the block proposer did not proposed one of the last f + 1 blocks false either
public boolean validateBlockCreator(Types.Block b, int f) {
        if (blocks.size() >= (f+1) && blocks.subList(blocks.size() - (f + 1), blocks.size()).
        stream().
        map(bl -> bl.getHeader().getM().getSender()).
        collect(Collectors.toList()).
        contains(b.getHeader().getM().getSender())) {
            logger.debug(format("[#%d] invalid Block", creatorID));
            return false;
        }
        return true;
    }
public boolean validateBlockCreator ( Types . Block b , int f ) { if ( blocks . size ( ) >= ( f + 1 ) && blocks . subList ( blocks . size ( ) - ( f + 1 ) , blocks . size ( ) ) . stream ( ) . map ( bl -> bl . getHeader ( ) . getM ( ) . getSender ( ) ) . collect ( Collectors . toList ( ) ) . contains ( b . getHeader ( ) . getM ( ) . getSender ( ) ) ) { logger . debug ( format ( "[#%d] invalid Block" , creatorID ) ) ; return false ; } return true ; }
Check if a block was proposed by a leader that proposed one of the last f+1 blocks.
Check if a block was proposed by a leader that proposed one of the last f + 1 blocks .