mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 05:44:05 +01:00
Rename readCommitHash to findCommitHash, make it static and return optional.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
39db3cc98b
commit
a925017e4b
@ -21,6 +21,8 @@ import java.net.URL;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
@ -140,14 +142,15 @@ public class Version {
|
||||
'}');
|
||||
}
|
||||
|
||||
public String readCommitHash() {
|
||||
public static Optional<String> findCommitHash() {
|
||||
try {
|
||||
String pth = getClass().getResource(getClass().getSimpleName() + ".class").toString();
|
||||
String pth = Objects.requireNonNull(Version.class.getResource(Version.class.getSimpleName() + ".class")).toString();
|
||||
String mnf = pth.substring(0, pth.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
|
||||
Attributes attr = new Manifest(new URL(mnf).openStream()).getMainAttributes();
|
||||
return attr.getValue("Implementation-Version");
|
||||
} catch (Exception ignored) { }
|
||||
return "unknown";
|
||||
return Optional.of(attr.getValue("Implementation-Version"));
|
||||
} catch (Exception ignored) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte COMPENSATION_REQUEST = (byte) 0x01;
|
||||
|
@ -150,7 +150,7 @@ public class GetInventoryRequestHandler implements MessageListener {
|
||||
|
||||
// node
|
||||
inventory.put(InventoryItem.version, Version.VERSION);
|
||||
inventory.put(InventoryItem.commitHash, new Version().readCommitHash());
|
||||
Version.findCommitHash().ifPresent(commitHash -> inventory.put(InventoryItem.commitHash, commitHash));
|
||||
inventory.put(InventoryItem.usedMemory, String.valueOf(Profiler.getUsedMemoryInBytes()));
|
||||
inventory.put(InventoryItem.jvmStartTime, String.valueOf(ManagementFactory.getRuntimeMXBean().getStartTime()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user