diff --git a/core/src/main/java/org/bitcoinj/core/Message.java b/core/src/main/java/org/bitcoinj/core/Message.java index 6eb4f229d..6882f47a8 100644 --- a/core/src/main/java/org/bitcoinj/core/Message.java +++ b/core/src/main/java/org/bitcoinj/core/Message.java @@ -21,13 +21,11 @@ import org.bitcoinj.base.Sha256Hash; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; -import java.util.Objects; /** *

A Message is a data structure that can be serialized/deserialized using the Bitcoin serialization format. @@ -43,39 +41,21 @@ public abstract class Message { protected final MessageSerializer serializer; - @Nullable - protected final NetworkParameters params; - protected Message() { - this.params = null; this.serializer = DummySerializer.DEFAULT; } - protected Message(NetworkParameters params) { - this.params = params; - this.serializer = params.getDefaultSerializer(); - } - protected Message(MessageSerializer serializer) { - this.params = null; - this.serializer = serializer; - } - - protected Message(NetworkParameters params, MessageSerializer serializer) { - this.params = params; this.serializer = serializer; } /** - * - * @param params NetworkParameters object. * @param payload Bitcoin protocol formatted byte array containing message content. * @param serializer the serializer to use for this message. * @throws ProtocolException */ - protected Message(NetworkParameters params, ByteBuffer payload, MessageSerializer serializer) throws ProtocolException { + protected Message(ByteBuffer payload, MessageSerializer serializer) throws ProtocolException { this.serializer = serializer; - this.params = params; try { parse(payload); @@ -85,15 +65,7 @@ public abstract class Message { } protected Message(ByteBuffer payload) throws ProtocolException { - this(null, payload, DummySerializer.DEFAULT); - } - - protected Message(ByteBuffer payload, MessageSerializer serializer) throws ProtocolException { - this(null, payload, serializer); - } - - protected Message(NetworkParameters params, ByteBuffer payload) throws ProtocolException { - this(params, payload, params.getDefaultSerializer()); + this(payload, DummySerializer.DEFAULT); } // These methods handle the serialization/deserialization using the custom Bitcoin protocol. @@ -143,9 +115,4 @@ public abstract class Message { public int getMessageSize() { return bitcoinSerialize().length; } - - /** Network parameters this message was created with. */ - public NetworkParameters getParams() { - return Objects.requireNonNull(params); - } } diff --git a/core/src/test/java/org/bitcoinj/core/PeerAddressTest.java b/core/src/test/java/org/bitcoinj/core/PeerAddressTest.java index 92c2d2edd..50b4fb5b4 100644 --- a/core/src/test/java/org/bitcoinj/core/PeerAddressTest.java +++ b/core/src/test/java/org/bitcoinj/core/PeerAddressTest.java @@ -45,7 +45,7 @@ public class PeerAddressTest { public void equalsContract() { EqualsVerifier.forClass(PeerAddress.class) .suppress(Warning.NONFINAL_FIELDS) - .withIgnoredFields("time", "params", "serializer") + .withIgnoredFields("time", "serializer") .usingGetClass() .verify(); }