diff --git a/build.gradle b/build.gradle index 7697799c90..1b1a7a4f2d 100644 --- a/build.gradle +++ b/build.gradle @@ -237,6 +237,15 @@ configure(project(':common')) { modules = ['javafx.graphics'] } + ext.getHash = { + def p1 = 'git rev-parse HEAD'.execute() + p1.waitFor() + return p1.text.substring(0,7) + } + + jar.manifest.attributes( + "Implementation-Version": getHash()) + dependencies { implementation project(':proto') annotationProcessor "org.projectlombok:lombok:$lombokVersion" diff --git a/common/src/main/java/bisq/common/app/Version.java b/common/src/main/java/bisq/common/app/Version.java index 17f3e4b652..729f2003a4 100644 --- a/common/src/main/java/bisq/common/app/Version.java +++ b/common/src/main/java/bisq/common/app/Version.java @@ -17,8 +17,12 @@ package bisq.common.app; +import java.net.URL; + import java.util.Arrays; import java.util.List; +import java.util.jar.Attributes; +import java.util.jar.Manifest; import lombok.extern.slf4j.Slf4j; @@ -136,6 +140,16 @@ public class Version { '}'); } + public String readCommitHash() { + try { + String pth = getClass().getResource(getClass().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"; + } + public static final byte COMPENSATION_REQUEST = (byte) 0x01; public static final byte REIMBURSEMENT_REQUEST = (byte) 0x01; public static final byte PROPOSAL = (byte) 0x01; diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java b/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java index 6bd646bc29..a8b6f4b7ec 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/GetInventoryRequestHandler.java @@ -29,7 +29,6 @@ import bisq.core.filter.FilterManager; import bisq.core.network.p2p.inventory.messages.GetInventoryRequest; import bisq.core.network.p2p.inventory.messages.GetInventoryResponse; import bisq.core.network.p2p.inventory.model.InventoryItem; -import bisq.core.network.p2p.inventory.model.RequestInfo; import bisq.network.p2p.network.Connection; import bisq.network.p2p.network.MessageListener; @@ -151,7 +150,7 @@ public class GetInventoryRequestHandler implements MessageListener { // node inventory.put(InventoryItem.version, Version.VERSION); - inventory.put(InventoryItem.commitHash, RequestInfo.COMMIT_HASH); + inventory.put(InventoryItem.commitHash, new Version().readCommitHash()); inventory.put(InventoryItem.usedMemory, String.valueOf(Profiler.getUsedMemoryInBytes())); inventory.put(InventoryItem.jvmStartTime, String.valueOf(ManagementFactory.getRuntimeMXBean().getStartTime())); diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/model/RequestInfo.java b/core/src/main/java/bisq/core/network/p2p/inventory/model/RequestInfo.java index c55a9e04ee..c84f69d410 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/model/RequestInfo.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/model/RequestInfo.java @@ -28,9 +28,6 @@ import org.jetbrains.annotations.Nullable; @Getter public class RequestInfo { - // Carries latest commit hash of feature changes (not latest commit as that is then the commit for editing that field) - public static final String COMMIT_HASH = "c07d47a8"; - private final long requestStartTime; @Setter private long responseTime; diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java index 1510092654..a1fdcecd26 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java @@ -83,7 +83,7 @@ public abstract class HistoricalDataStoreService