Skip to content

Commit

Permalink
Switch bit to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Jul 2, 2019
1 parent c136b90 commit 5f47cce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions node/src/PeerClient.java
Expand Up @@ -22,7 +22,7 @@ public PeerClient(SnowBlossomNode node, PeerInfo info)
throws Exception
{
ManagedChannel channel;
if (info.getTls())
if (info.getConnectionType().equals(PeerInfo.ConnectionType.GRPC_TLS))
{
AddressSpecHash node_address = new AddressSpecHash(info.getNodeSnowAddress());
SslContext ssl_ctx = GrpcSslContexts.forClient()
Expand All @@ -35,13 +35,17 @@ public PeerClient(SnowBlossomNode node, PeerInfo info)
.sslContext(ssl_ctx)
.build();
}
else
else if (info.getConnectionType().equals(PeerInfo.ConnectionType.GRPC_TCP))
{
channel = ManagedChannelBuilder
.forAddress(info.getHost(), info.getPort())
.usePlaintext(true)
.build();
}
else
{
throw new Exception("Unknown connection type: " + info.getConnectionType());
}
PeerLink link = null;

try
Expand Down
4 changes: 2 additions & 2 deletions node/src/Peerage.java
Expand Up @@ -565,7 +565,7 @@ private List<PeerInfo> getSelfPeers()
.setLearned(System.currentTimeMillis())
.setVersion(Globals.VERSION)
.setNodeId(node_id)
.setTls(false)
.setConnectionType(PeerInfo.ConnectionType.GRPC_TCP)
.build();

self_peers.add(pi);
Expand All @@ -588,7 +588,7 @@ private List<PeerInfo> getSelfPeers()
.setLearned(System.currentTimeMillis())
.setVersion(Globals.VERSION)
.setNodeId(node_id)
.setTls(true)
.setConnectionType(PeerInfo.ConnectionType.GRPC_TLS)
.setNodeSnowAddress(node.getTlsAddress().getBytes())
.build();

Expand Down
7 changes: 6 additions & 1 deletion protolib/snowblossom.proto
Expand Up @@ -195,8 +195,13 @@ message PeerInfo {
int64 learned = 5;
string version = 6;
bytes node_id = 7;
bool tls = 8;
//bool tls = 8; bad idea, using enum
bytes node_snow_address = 9; //Used for TLS
enum ConnectionType {
GRPC_TCP = 0;
GRPC_TLS = 1;
}
ConnectionType connection_type = 10;

}

Expand Down

0 comments on commit 5f47cce

Please sign in to comment.