Search in sources :

Example 1 with PunishmentParameters

use of co.rsk.scoring.PunishmentParameters in project rskj by rsksmart.

the class RskFactory method getPeerScoringManager.

@Bean
public PeerScoringManager getPeerScoringManager(SystemProperties config) {
    int nnodes = config.scoringNumberOfNodes();
    long nodePunishmentDuration = config.scoringNodesPunishmentDuration();
    int nodePunishmentIncrement = config.scoringNodesPunishmentIncrement();
    long nodePunhishmentMaximumDuration = config.scoringNodesPunishmentMaximumDuration();
    long addressPunishmentDuration = config.scoringAddressesPunishmentDuration();
    int addressPunishmentIncrement = config.scoringAddressesPunishmentIncrement();
    long addressPunishmentMaximunDuration = config.scoringAddressesPunishmentMaximumDuration();
    return new PeerScoringManager(nnodes, new PunishmentParameters(nodePunishmentDuration, nodePunishmentIncrement, nodePunhishmentMaximumDuration), new PunishmentParameters(addressPunishmentDuration, addressPunishmentIncrement, addressPunishmentMaximunDuration));
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) PunishmentParameters(co.rsk.scoring.PunishmentParameters) Bean(org.springframework.context.annotation.Bean)

Example 2 with PunishmentParameters

use of co.rsk.scoring.PunishmentParameters in project rskj by rsksmart.

the class RskContext method getPeerScoringManager.

public synchronized PeerScoringManager getPeerScoringManager() {
    checkIfNotClosed();
    if (peerScoringManager == null) {
        RskSystemProperties rskSystemProperties = getRskSystemProperties();
        List<String> bannedPeerIPs = rskSystemProperties.bannedPeerIPList();
        List<String> bannedPeerIDs = rskSystemProperties.bannedPeerIDList();
        peerScoringManager = new PeerScoringManager(() -> new PeerScoring(rskSystemProperties.scoringPunishmentEnabled()), rskSystemProperties.scoringNumberOfNodes(), new PunishmentParameters(rskSystemProperties.scoringNodesPunishmentDuration(), rskSystemProperties.scoringNodesPunishmentIncrement(), rskSystemProperties.scoringNodesPunishmentMaximumDuration()), new PunishmentParameters(rskSystemProperties.scoringAddressesPunishmentDuration(), rskSystemProperties.scoringAddressesPunishmentIncrement(), rskSystemProperties.scoringAddressesPunishmentMaximumDuration()), bannedPeerIPs, bannedPeerIDs);
    }
    return peerScoringManager;
}
Also used : PeerScoring(co.rsk.scoring.PeerScoring) PeerScoringManager(co.rsk.scoring.PeerScoringManager) PunishmentParameters(co.rsk.scoring.PunishmentParameters)

Aggregations

PeerScoringManager (co.rsk.scoring.PeerScoringManager)2 PunishmentParameters (co.rsk.scoring.PunishmentParameters)2 PeerScoring (co.rsk.scoring.PeerScoring)1 Bean (org.springframework.context.annotation.Bean)1