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

Commit

Permalink
Ibft transmitted packets are logged by gossiper
Browse files Browse the repository at this point in the history
Messages which originate with the current node are logged in the
gossiper such that if a remote peer sends a packet which originated
from the local back to the local node, it should not go back out
again.
  • Loading branch information
tmohay committed Jan 24, 2019
1 parent 11de8af commit 4188eb7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

/** Class responsible for rebroadcasting IBFT messages to known validators */
public class IbftGossip {

private final ValidatorMulticaster multicaster;

// Size of the seenMessages cache, should end up utilising 65bytes * this number + some meta data
Expand Down Expand Up @@ -100,9 +101,16 @@ public boolean gossipMessage(final Message message) {
final List<Address> excludeAddressesList =
Lists.newArrayList(
message.getConnection().getPeer().getAddress(), signedData.getSender());
multicaster.send(messageData, excludeAddressesList);
seenMessages.add(signature);
transmit(messageData, signature, excludeAddressesList);
return true;
}
}

public void transmit(
final MessageData messageData,
final Signature signature,
final List<Address> excludeAddressesList) {
multicaster.send(messageData, excludeAddressesList);
seenMessages.add(signature);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
*/
package tech.pegasys.pantheon.consensus.ibft.network;

import static java.util.Collections.emptyList;

import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier;
import tech.pegasys.pantheon.consensus.ibft.IbftGossip;
import tech.pegasys.pantheon.consensus.ibft.messagedata.CommitMessageData;
import tech.pegasys.pantheon.consensus.ibft.messagedata.NewRoundMessageData;
import tech.pegasys.pantheon.consensus.ibft.messagedata.PrepareMessageData;
Expand All @@ -36,12 +39,12 @@
public class IbftMessageTransmitter {

private final MessageFactory messageFactory;
private final ValidatorMulticaster multicaster;
private final IbftGossip networkInterface;

public IbftMessageTransmitter(
final MessageFactory messageFactory, final ValidatorMulticaster multicaster) {
final MessageFactory messageFactory, final IbftGossip networkInterface) {
this.messageFactory = messageFactory;
this.multicaster = multicaster;
this.networkInterface = networkInterface;
}

public void multicastProposal(final ConsensusRoundIdentifier roundIdentifier, final Block block) {
Expand All @@ -50,7 +53,7 @@ public void multicastProposal(final ConsensusRoundIdentifier roundIdentifier, fi

final ProposalMessageData message = ProposalMessageData.create(signedPayload);

multicaster.send(message);
networkInterface.transmit(message, signedPayload.getSignature(), emptyList());
}

public void multicastPrepare(final ConsensusRoundIdentifier roundIdentifier, final Hash digest) {
Expand All @@ -59,7 +62,7 @@ public void multicastPrepare(final ConsensusRoundIdentifier roundIdentifier, fin

final PrepareMessageData message = PrepareMessageData.create(signedPayload);

multicaster.send(message);
networkInterface.transmit(message, signedPayload.getSignature(), emptyList());
}

public void multicastCommit(
Expand All @@ -71,7 +74,7 @@ public void multicastCommit(

final CommitMessageData message = CommitMessageData.create(signedPayload);

multicaster.send(message);
networkInterface.transmit(message, signedPayload.getSignature(), emptyList());
}

public void multicastRoundChange(
Expand All @@ -83,7 +86,7 @@ public void multicastRoundChange(

final RoundChangeMessageData message = RoundChangeMessageData.create(signedPayload);

multicaster.send(message);
networkInterface.transmit(message, signedPayload.getSignature(), emptyList());
}

public void multicastNewRound(
Expand All @@ -97,6 +100,6 @@ public void multicastNewRound(

final NewRoundMessageData message = NewRoundMessageData.create(signedPayload);

multicaster.send(message);
networkInterface.transmit(message, signedPayload.getSignature(), emptyList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import tech.pegasys.pantheon.consensus.common.ValidatorProvider;
import tech.pegasys.pantheon.consensus.ibft.BlockTimer;
import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier;
import tech.pegasys.pantheon.consensus.ibft.IbftGossip;
import tech.pegasys.pantheon.consensus.ibft.RoundTimer;
import tech.pegasys.pantheon.consensus.ibft.blockcreation.IbftBlockCreatorFactory;
import tech.pegasys.pantheon.consensus.ibft.blockcreation.ProposerSelector;
Expand Down Expand Up @@ -64,7 +65,8 @@ public IbftFinalState(
this.blockCreatorFactory = blockCreatorFactory;
this.messageFactory = messageFactory;
this.clock = clock;
this.messageTransmitter = new IbftMessageTransmitter(messageFactory, validatorMulticaster);
this.messageTransmitter =
new IbftMessageTransmitter(messageFactory, new IbftGossip(validatorMulticaster));
}

public int getQuorum() {
Expand Down

0 comments on commit 4188eb7

Please sign in to comment.