|
|
@ -14,6 +14,7 @@ package tech.pegasys.pantheon.consensus.ibft; |
|
|
|
|
|
|
|
|
|
|
|
import tech.pegasys.pantheon.consensus.ibft.network.ValidatorMulticaster; |
|
|
|
import tech.pegasys.pantheon.consensus.ibft.network.ValidatorMulticaster; |
|
|
|
import tech.pegasys.pantheon.ethereum.core.Address; |
|
|
|
import tech.pegasys.pantheon.ethereum.core.Address; |
|
|
|
|
|
|
|
import tech.pegasys.pantheon.ethereum.core.Hash; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
@ -42,11 +43,11 @@ public class UniqueMessageMulticaster implements ValidatorMulticaster { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set that starts evicting members when it hits capacity
|
|
|
|
// Set that starts evicting members when it hits capacity
|
|
|
|
private final Set<Integer> seenMessages = |
|
|
|
private final Set<Hash> seenMessages = |
|
|
|
Collections.newSetFromMap( |
|
|
|
Collections.newSetFromMap( |
|
|
|
new LinkedHashMap<Integer, Boolean>() { |
|
|
|
new LinkedHashMap<Hash, Boolean>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected boolean removeEldestEntry(final Map.Entry<Integer, Boolean> eldest) { |
|
|
|
protected boolean removeEldestEntry(final Map.Entry<Hash, Boolean> eldest) { |
|
|
|
return size() > maxSeenMessages; |
|
|
|
return size() > maxSeenMessages; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -58,7 +59,7 @@ public class UniqueMessageMulticaster implements ValidatorMulticaster { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void send(final MessageData message, final Collection<Address> blackList) { |
|
|
|
public void send(final MessageData message, final Collection<Address> blackList) { |
|
|
|
final int uniqueID = message.hashCode(); |
|
|
|
final Hash uniqueID = Hash.hash(message.getData()); |
|
|
|
if (seenMessages.contains(uniqueID)) { |
|
|
|
if (seenMessages.contains(uniqueID)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|