Skip to content

Commit

Permalink
refactored network identifier to chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandraRoatis committed Sep 28, 2018
1 parent f3b6da4 commit cb866d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
38 changes: 19 additions & 19 deletions modAionImpl/src/org/aion/zero/impl/config/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ public enum Network {
CUSTOM("custom", 0);

private final String name;
private int identifier;
private int chainId;

/**
* Constructor.
*
* @param _name network name
* @param _identifier network identifier
* @param _chainId chain identifier
*/
Network(String _name, int _identifier) {
Network(String _name, int _chainId) {
this.name = _name;
this.identifier = _identifier;
this.chainId = _chainId;
}

@Override
public String toString() {
return this.name;
}

public int getIdentifier() {
return identifier;
public int getChainId() {
return chainId;
}

/**
Expand Down Expand Up @@ -84,26 +84,26 @@ public static Network determineNetwork(String network) {
}

/**
* Utility method that determines the correct network based on the given identifier.
* Utility method that determines the correct network based on the given chain identifier.
*
* @param identifier a positive integer value representing the network identifier
* @param chainId a positive integer value representing the network chain identifier
* @return the network object corresponding to the int value or null when the value is not
* mapped to an object.
*/
public static Network determineNetwork(int identifier) {
if (identifier < 0) {
public static Network determineNetwork(int chainId) {
if (chainId < 0) {
return null;
}

for (Network net : Network.values()) {
if (identifier == net.getIdentifier()) {
if (chainId == net.getChainId()) {
return net;
}
}

// custom networks may have any positive identifier not already taken
// custom networks may have any positive chainId not already taken by other defined networks
Network net = Network.CUSTOM;
net.identifier = identifier;
net.chainId = chainId;
return net;
}

Expand All @@ -113,17 +113,17 @@ public static String valuesString() {
}

/**
* Generates a custom network with the given identifier.
* Generates a custom network with the given chain identifier.
*
* @param identifier a positive integer value representing the network identifier
* @return a custom network object with the given identifier.
* @param chainId a positive integer value representing the network chain identifier
* @return a custom network object with the given chain identifier.
*/
public static Object getCustomNet(int identifier) {
if (identifier < 0) {
public static Network getCustomNet(int chainId) {
if (chainId < 0) {
return null;
}
Network net = Network.CUSTOM;
net.identifier = identifier;
net.chainId = chainId;
return net;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private Object intToNetworkMappings() {
List<Object> parameters = new ArrayList<>();

for (Network net : Network.values()) {
parameters.add(new Object[] {net.getIdentifier(), net});
parameters.add(new Object[] {net.getChainId(), net});
}

parameters.add(new Object[] {-1, null});
Expand Down

0 comments on commit cb866d3

Please sign in to comment.