From 0c1d308b5be984d775b9b6561b06293c68ddaf12 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 18 Feb 2013 15:51:24 +0100 Subject: [PATCH] Refactor version constants a bit. Resolves issue 206. --- .../main/java/com/google/bitcoin/core/VersionMessage.java | 7 ++++++- .../java/com/google/bitcoin/core/VersionMessageTest.java | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/VersionMessage.java b/core/src/main/java/com/google/bitcoin/core/VersionMessage.java index 688dd24d..d2a06181 100644 --- a/core/src/main/java/com/google/bitcoin/core/VersionMessage.java +++ b/core/src/main/java/com/google/bitcoin/core/VersionMessage.java @@ -72,6 +72,11 @@ public class VersionMessage extends Message { */ public boolean relayTxesBeforeFilter; + /** The version of this library release, as a string. */ + public static final String BITCOINJ_VERSION = "0.7-SNAPSHOT"; + /** The value that is prepended to the subVer field of this application. */ + public static final String LIBRARY_SUBVER = "/BitCoinJ:" + BITCOINJ_VERSION + "/"; + public VersionMessage(NetworkParameters params, byte[] msg) throws ProtocolException { super(params, msg, 0); } @@ -101,7 +106,7 @@ public class VersionMessage extends Message { } catch (UnknownHostException e) { throw new RuntimeException(e); // Cannot happen (illegal IP length). } - subVer = "/BitCoinJ:0.7-SNAPSHOT/"; + subVer = LIBRARY_SUBVER; bestHeight = newBestHeight; this.relayTxesBeforeFilter = relayTxesBeforeFilter; diff --git a/core/src/test/java/com/google/bitcoin/core/VersionMessageTest.java b/core/src/test/java/com/google/bitcoin/core/VersionMessageTest.java index 7154cb5d..10d9994a 100644 --- a/core/src/test/java/com/google/bitcoin/core/VersionMessageTest.java +++ b/core/src/test/java/com/google/bitcoin/core/VersionMessageTest.java @@ -1,10 +1,10 @@ package com.google.bitcoin.core; -import static org.junit.Assert.assertTrue; - import org.junit.Test; import org.spongycastle.util.encoders.Hex; +import static org.junit.Assert.assertTrue; + public class VersionMessageTest { @Test // Test that we can decode version messages which miss data which some old nodes may not include