From 4e8f1bb153bdd160ed6641925be1d2a45d999a75 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Tue, 26 May 2015 00:02:20 +0100 Subject: [PATCH] Block.parseHeader() and Block.parseTransactions() are now protected, so they can be called from subclasses. --- core/src/main/java/org/bitcoinj/core/Block.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/Block.java b/core/src/main/java/org/bitcoinj/core/Block.java index 3e17e397..f8d9b36f 100644 --- a/core/src/main/java/org/bitcoinj/core/Block.java +++ b/core/src/main/java/org/bitcoinj/core/Block.java @@ -180,7 +180,7 @@ public class Block extends Message { hash = null; } - private void parseHeader() throws ProtocolException { + protected void parseHeader() throws ProtocolException { if (headerParsed) return; @@ -198,7 +198,7 @@ public class Block extends Message { headerBytesValid = parseRetain; } - private void parseTransactions() throws ProtocolException { + protected void parseTransactions() throws ProtocolException { if (transactionsParsed) return; @@ -561,6 +561,12 @@ public class Block extends Message { public Block cloneAsHeader() { maybeParseHeader(); Block block = new Block(params); + copyBitcoinHeaderTo(block); + return block; + } + + /** Copy the block without transactions into the provided empty block. */ + protected final void copyBitcoinHeaderTo(final Block block) { block.nonce = nonce; block.prevBlockHash = prevBlockHash; block.merkleRoot = getMerkleRoot(); @@ -569,7 +575,6 @@ public class Block extends Message { block.difficultyTarget = difficultyTarget; block.transactions = null; block.hash = getHash(); - return block; } /**