Search in sources :

Example 1 with ReasonCode

use of org.ethereum.net.message.ReasonCode in project rskj by rsksmart.

the class ChannelManagerImpl method processNewPeer.

private void processNewPeer(Channel channel, List<Channel> processedChannels) {
    ReasonCode reason = getNewPeerDisconnectionReason(channel);
    if (reason != null) {
        disconnect(channel, reason);
    } else {
        addToActives(channel);
    }
    processedChannels.add(channel);
}
Also used : ReasonCode(org.ethereum.net.message.ReasonCode)

Example 2 with ReasonCode

use of org.ethereum.net.message.ReasonCode in project rskj by rsksmart.

the class ChannelManagerImpl method processNewPeers.

private void processNewPeers() {
    if (!CollectionUtils.isEmpty(newPeers)) {
        final List<Channel> processed = new ArrayList<>();
        newPeers.stream().filter(Channel::isProtocolsInitialized).forEach(channel -> {
            ReasonCode reason = getNewPeerDisconnectionReason(channel);
            if (reason == null) {
                process(channel);
            } else {
                disconnect(channel, reason);
            }
            processed.add(channel);
        });
        newPeers.removeAll(processed);
    }
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ReasonCode(org.ethereum.net.message.ReasonCode)

Aggregations

ReasonCode (org.ethereum.net.message.ReasonCode)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1