Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Ibft to uniquely ID messages by their hash #730

Merged
merged 4 commits into from
Feb 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import tech.pegasys.pantheon.consensus.ibft.network.ValidatorMulticaster;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;

import java.util.Collection;
Expand Down Expand Up @@ -42,11 +43,11 @@ public UniqueMessageMulticaster(final ValidatorMulticaster multicaster) {
}

// Set that starts evicting members when it hits capacity
private final Set<Integer> seenMessages =
private final Set<Hash> seenMessages =
Collections.newSetFromMap(
new LinkedHashMap<Integer, Boolean>() {
new LinkedHashMap<Hash, Boolean>() {
@Override
protected boolean removeEldestEntry(final Map.Entry<Integer, Boolean> eldest) {
protected boolean removeEldestEntry(final Map.Entry<Hash, Boolean> eldest) {
return size() > maxSeenMessages;
}
});
Expand All @@ -58,7 +59,7 @@ public void send(final MessageData message) {

@Override
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)) {
return;
}
Expand Down