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

Rename IBFT networking classes #555

Merged
merged 12 commits into from
Jan 16, 2019
Merged

Rename IBFT networking classes #555

merged 12 commits into from
Jan 16, 2019

Conversation

rain-on
Copy link
Contributor

@rain-on rain-on commented Jan 14, 2019

No description provided.

@rain-on rain-on requested review from jframe and CjHare January 14, 2019 06:39

public interface PeerCollection {

void peerAdded(PeerConnection newConnection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these both be in the present tense rather then the past tense? (addPeer and removePeer or add && remove)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -17,10 +17,9 @@

import java.util.Collection;

public interface IbftMulticaster {
public interface ValidatorMulticaster {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something doesn't sit right with this name, I suspect it should be ValidatorMulticast (not certain on the exact reason, it might be something grammar related)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured classes are normally nouns, functions are normally verb-noun composition...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've found the reason; multicast is both a verb and a noun
https://en.oxforddictionaries.com/definition/multicast
When creating a compound noun (as we are here), then you have at least two options:
If you treat multicast as a noun:ValidatorMulticast
If you treat multicast as a verb ValidatorMulticaster

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As both are valid I'll suggest @jframe chime in on whether in this context multicast fits better as a verb or noun

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my head, multicast is a verb ... but broadcast could clearly be a noun ... go figure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is for ValidatorMulticaster. The name ValidatorMulticast doesn't seem right even though it might be valid from a grammar point of view.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, ValidatorMulticaster it is then 👍

final Collection<Address> validators = validatorProvider.getValidators();
sendMessageToSpecificAddresses(validators, message);
}

@Override
public void multicastToValidatorsExcept(
final MessageData message, final Collection<Address> exceptAddresses) {
public void send(final MessageData message, final Collection<Address> blackList) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the rename to blacklist 👍

@@ -17,10 +17,9 @@

import java.util.Collection;

public interface IbftMulticaster {
public interface ValidatorMulticaster {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is for ValidatorMulticaster. The name ValidatorMulticast doesn't seem right even though it might be valid from a grammar point of view.

final Address peerAddress = removedConnection.getPeer().getAddress();
peerConnections.remove(peerAddress);
}

@Override
public void multicastToValidators(final MessageData message) {
public void send(final MessageData message) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using send is nice, much simpler.


import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection;

public interface PeerCollection {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so sure about this name, it's not really a collection.

@@ -125,10 +125,10 @@ public static TestContext createTestEnvironment(
final KeyPair nodeKeys = networkNodes.getLocalNode().getNodeKeyPair();

// Use a stubbed version of the multicaster, to prevent creating PeerConnections etc.
final StubIbftMulticaster stubbedNetworkPeers = new StubIbftMulticaster();
final StubValidatorMulticaster stubbedMulticaster = new StubValidatorMulticaster();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be just called multicaster, the stubbed quality 'should' be irrelevant i.e. there's no need to know it's no the real thing (good ol' polymorphism)

@@ -35,7 +35,7 @@

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the IbftMulticaster has been renamed, perhaps the IBFT prefix should be dropped and changed to include validator (as that's who being gossiped with?), ValidatorGossiper?

@rain-on rain-on merged commit ba6e6f4 into PegaSysEng:master Jan 16, 2019
iikirilov pushed a commit to vinistevam/pantheon that referenced this pull request Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants