forked from Consensys/orion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce PartyInfo controller and supporting objects Modified Config to store URL objects for 'url' and 'othernodes' keys
- Loading branch information
1 parent
6f516b2
commit a8011c3
Showing
13 changed files
with
238 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/net/consensys/athena/api/network/NetworkNodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.consensys.athena.api.network; | ||
|
||
import java.net.URL; | ||
import java.security.PublicKey; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
|
||
/** Details of other nodes on the network */ | ||
public interface NetworkNodes { | ||
|
||
/** | ||
* URL of this node | ||
* | ||
* @return URL of node | ||
*/ | ||
URL url(); | ||
|
||
/** | ||
* List of URLs of other nodes on the network | ||
* | ||
* @return | ||
*/ | ||
HashSet<URL> nodeURLs(); | ||
|
||
/** | ||
* Map from URL to public key for all discovered nodes. | ||
* | ||
* @return | ||
*/ | ||
HashMap<URL, PublicKey> nodePKs(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/net/consensys/athena/impl/network/MemoryNetworkNodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package net.consensys.athena.impl.network; | ||
|
||
import net.consensys.athena.api.config.Config; | ||
import net.consensys.athena.api.network.NetworkNodes; | ||
|
||
import java.net.URL; | ||
import java.security.PublicKey; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
|
||
public class MemoryNetworkNodes implements NetworkNodes { | ||
|
||
private URL url; | ||
private HashSet<URL> nodeURLs; | ||
private HashMap<URL, PublicKey> nodePKs; | ||
|
||
public MemoryNetworkNodes() { | ||
nodeURLs = new HashSet<>(); | ||
nodePKs = new HashMap<>(); | ||
} | ||
|
||
public MemoryNetworkNodes(Config config) { | ||
url = config.url(); | ||
if (config.otherNodes().length > 0) { | ||
nodeURLs = new HashSet<>(Arrays.asList(config.otherNodes())); | ||
} else { | ||
nodeURLs = new HashSet<>(); | ||
} | ||
|
||
nodePKs = new HashMap<>(); | ||
} | ||
|
||
/** | ||
* Add the URL of a node to the nodeURLs list. | ||
* | ||
* @param node URL of new node | ||
*/ | ||
public void addNodeURL(URL node) { | ||
this.nodeURLs.add(node); | ||
} | ||
|
||
/** | ||
* Add a node's URL and PublcKey to the nodeURLs and nodePKs lists | ||
* | ||
* @param node URL of new node | ||
* @param nodePk PublicKey of new node | ||
*/ | ||
public void addNode(URL node, PublicKey nodePk) { | ||
this.nodeURLs.add(node); | ||
this.nodePKs.put(node, nodePk); | ||
} | ||
|
||
@Override | ||
public URL url() { | ||
return url; | ||
} | ||
|
||
@Override | ||
public HashSet<URL> nodeURLs() { | ||
return nodeURLs; | ||
} | ||
|
||
public HashMap<URL, PublicKey> nodePKs() { | ||
return nodePKs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.