From 95060faa206bd15585cb504f6ae5a695543286fe Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Fri, 23 Oct 2015 20:55:35 +0100 Subject: [PATCH] Update subclasses to match bitcoinj API changes Update AltcoinBlock and AltcoinSerializer to handle offset as a parameter when parsing blocks. --- .../java/org/bitcoinj/core/AltcoinBlock.java | 17 +++++++++++------ .../org/libdohj/core/AltcoinSerializer.java | 9 ++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/bitcoinj/core/AltcoinBlock.java b/src/main/java/org/bitcoinj/core/AltcoinBlock.java index 6c506ba8..9620c9b6 100644 --- a/src/main/java/org/bitcoinj/core/AltcoinBlock.java +++ b/src/main/java/org/bitcoinj/core/AltcoinBlock.java @@ -60,14 +60,18 @@ public class AltcoinBlock extends org.bitcoinj.core.Block { private ScryptHash scryptHash; - /** Special case constructor, used for the genesis node, cloneAsHeader and unit tests. */ + /** Special case constructor, used for the genesis node, cloneAsHeader and unit tests. + * @param params NetworkParameters object. + */ public AltcoinBlock(final NetworkParameters params, final long version) { super(params, version); } - /** Special case constructor, used for the genesis node, cloneAsHeader and unit tests. */ - public AltcoinBlock(NetworkParameters params, byte[] payloadBytes) { - this(params, payloadBytes, params.getDefaultSerializer(), payloadBytes.length); + /** Special case constructor, used for the genesis node, cloneAsHeader and unit tests. + * @param params NetworkParameters object. + */ + public AltcoinBlock(final NetworkParameters params, final byte[] payloadBytes) { + this(params, payloadBytes, 0, params.getDefaultSerializer(), payloadBytes.length); } /** @@ -78,9 +82,10 @@ public class AltcoinBlock extends org.bitcoinj.core.Block { * as the length will be provided as part of the header. If unknown then set to Message.UNKNOWN_LENGTH * @throws ProtocolException */ - public AltcoinBlock(NetworkParameters params, byte[] payloadBytes, MessageSerializer serializer, int length) + public AltcoinBlock(final NetworkParameters params, final byte[] payloadBytes, + final int offset, final MessageSerializer serializer, final int length) throws ProtocolException { - super(params, payloadBytes, serializer, length); + super(params, payloadBytes, offset, serializer, length); } public AltcoinBlock(NetworkParameters params, byte[] payloadBytes, int offset, diff --git a/src/main/java/org/libdohj/core/AltcoinSerializer.java b/src/main/java/org/libdohj/core/AltcoinSerializer.java index 42e4a905..1a00b4d3 100644 --- a/src/main/java/org/libdohj/core/AltcoinSerializer.java +++ b/src/main/java/org/libdohj/core/AltcoinSerializer.java @@ -22,12 +22,7 @@ public class AltcoinSerializer extends BitcoinSerializer { } @Override - public Block makeBlock(byte[] payloadBytes) throws ProtocolException { - return new AltcoinBlock(getParameters(), payloadBytes, this, payloadBytes.length); - } - - @Override - public Block makeBlock(byte[] payloadBytes, int length) throws ProtocolException { - return new AltcoinBlock(getParameters(), payloadBytes, this, length); + public Block makeBlock(final byte[] payloadBytes, final int offset, final int length) throws ProtocolException { + return new AltcoinBlock(getParameters(), payloadBytes, offset, this, length); } }