Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Update hello string according to ethereum/EIPs#58
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashatyrev committed Mar 2, 2016
1 parent 77cd1a0 commit ef6d7c3
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* This class contains static values of messages on the network. These message
Expand Down Expand Up @@ -48,13 +50,20 @@ public HelloMessage createHelloMessage(String peerId, int listenPort) {

private String buildHelloAnnouncement() {
String version = config.projectVersion();
String numberVersion = version;
Pattern pattern = Pattern.compile("^\\d+(\\.\\d+)*");
Matcher matcher = pattern.matcher(numberVersion);
if (matcher.find()) {
numberVersion = numberVersion.substring(matcher.start(), matcher.end());
}
String system = System.getProperty("os.name");
if (system.contains(" "))
system = system.substring(0, system.indexOf(" "));
if (System.getProperty("java.vm.vendor").contains("Android"))
system = "Android";
String phrase = config.helloPhrase();

return String.format("Ethereum(J)/v%s/%s/%s/Java", version, phrase, system);
return String.format("Ethereum(J)/v%s/%s/%s/Java/%s", numberVersion, system,
config.projectVersionModifier().equalsIgnoreCase("release") ? "Release" : "Dev", phrase);
}
}

0 comments on commit ef6d7c3

Please sign in to comment.