From 1463423310ce9dcbcf79dbe0aa347a338de02489 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Wed, 1 Sep 2021 07:55:16 -0700 Subject: [PATCH] Block: Add @VisibleForTesting to some mutating methods These methods should only be used for testing and will hopefully be deprecated and/or refactored to another class in the future. --- core/src/main/java/org/bitcoinj/core/Block.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/org/bitcoinj/core/Block.java b/core/src/main/java/org/bitcoinj/core/Block.java index 86ae61b9a..002c17b9b 100644 --- a/core/src/main/java/org/bitcoinj/core/Block.java +++ b/core/src/main/java/org/bitcoinj/core/Block.java @@ -498,6 +498,7 @@ public class Block extends Message { *

This can loop forever if a solution cannot be found solely by incrementing nonce. It doesn't change * extraNonce.

*/ + @VisibleForTesting public void solve() { while (true) { try { @@ -773,6 +774,7 @@ public class Block extends Message { } /** Exists only for unit testing. */ + @VisibleForTesting void setMerkleRoot(Sha256Hash value) { unCacheHeader(); merkleRoot = value; @@ -823,6 +825,7 @@ public class Block extends Message { return prevBlockHash; } + @VisibleForTesting void setPrevBlockHash(Sha256Hash prevBlockHash) { unCacheHeader(); this.prevBlockHash = prevBlockHash; @@ -844,6 +847,7 @@ public class Block extends Message { return new Date(getTimeSeconds()*1000); } + @VisibleForTesting public void setTime(long time) { unCacheHeader(); this.time = time; @@ -864,6 +868,7 @@ public class Block extends Message { } /** Sets the difficulty target in compact form. */ + @VisibleForTesting public void setDifficultyTarget(long compactForm) { unCacheHeader(); this.difficultyTarget = compactForm; @@ -879,6 +884,7 @@ public class Block extends Message { } /** Sets the nonce and clears any cached data. */ + @VisibleForTesting public void setNonce(long nonce) { unCacheHeader(); this.nonce = nonce; @@ -947,6 +953,7 @@ public class Block extends Message { * * @param height block height, if known, or -1 otherwise. */ + @VisibleForTesting Block createNextBlock(@Nullable final Address to, final long version, @Nullable TransactionOutPoint prevOut, final long time, final byte[] pubKey, final Coin coinbaseValue,