Search in sources :

Example 1 with PunishLogComparator

use of io.nuls.consensus.poc.storage.utils.PunishLogComparator in project nuls by nuls-io.

the class CacheLoader method loadYellowPunishList.

public List<PunishLogPo> loadYellowPunishList(List<PunishLogPo> allPunishList, int roundSize) {
    List<PunishLogPo> list = new ArrayList<>();
    BlockHeader blockHeader = blockService.getBestBlockHeader().getData();
    if (null == blockHeader) {
        return list;
    }
    BlockExtendsData roundData = new BlockExtendsData(blockHeader.getExtend());
    long breakRoundIndex = roundData.getRoundIndex() - roundSize;
    for (PunishLogPo po : allPunishList) {
        if (po.getType() == PunishType.RED.getCode()) {
            continue;
        }
        if (po.getRoundIndex() <= breakRoundIndex) {
            continue;
        }
        list.add(po);
    }
    Collections.sort(list, new PunishLogComparator());
    return list;
}
Also used : BlockExtendsData(io.nuls.consensus.poc.model.BlockExtendsData) PunishLogComparator(io.nuls.consensus.poc.storage.utils.PunishLogComparator) ArrayList(java.util.ArrayList) BlockHeader(io.nuls.kernel.model.BlockHeader) PunishLogPo(io.nuls.consensus.poc.storage.po.PunishLogPo)

Example 2 with PunishLogComparator

use of io.nuls.consensus.poc.storage.utils.PunishLogComparator in project nuls by nuls-io.

the class CacheLoader method loadRedPunishList.

public List<PunishLogPo> loadRedPunishList(List<PunishLogPo> allPunishList) {
    List<PunishLogPo> list = new ArrayList<>();
    for (PunishLogPo po : allPunishList) {
        if (po.getType() == PunishType.RED.getCode()) {
            list.add(po);
        }
    }
    Collections.sort(list, new PunishLogComparator());
    return list;
}
Also used : PunishLogComparator(io.nuls.consensus.poc.storage.utils.PunishLogComparator) ArrayList(java.util.ArrayList) PunishLogPo(io.nuls.consensus.poc.storage.po.PunishLogPo)

Aggregations

PunishLogPo (io.nuls.consensus.poc.storage.po.PunishLogPo)2 PunishLogComparator (io.nuls.consensus.poc.storage.utils.PunishLogComparator)2 ArrayList (java.util.ArrayList)2 BlockExtendsData (io.nuls.consensus.poc.model.BlockExtendsData)1 BlockHeader (io.nuls.kernel.model.BlockHeader)1