From 4e91a274d93e0aafafa55c6547089feae4a6f06d Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Wed, 9 Aug 2023 00:47:52 +0200 Subject: [PATCH] Block: annotate and document the `null` transactions case for main constructor --- core/src/main/java/org/bitcoinj/core/Block.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/Block.java b/core/src/main/java/org/bitcoinj/core/Block.java index 0e13913c1..30e420d71 100644 --- a/core/src/main/java/org/bitcoinj/core/Block.java +++ b/core/src/main/java/org/bitcoinj/core/Block.java @@ -195,10 +195,10 @@ public class Block extends BaseMessage { * @param time time when the block was mined. * @param difficultyTarget Number which this block hashes lower than. * @param nonce Arbitrary number to make the block hash lower than the target. - * @param transactions List of transactions including the coinbase. + * @param transactions List of transactions including the coinbase, or {@code null} for header-only blocks */ public Block(long version, Sha256Hash prevBlockHash, Sha256Hash merkleRoot, Instant time, - long difficultyTarget, long nonce, List transactions) { + long difficultyTarget, long nonce, @Nullable List transactions) { super(); this.version = version; this.prevBlockHash = prevBlockHash; @@ -219,12 +219,12 @@ public class Block extends BaseMessage { * @param time UNIX time seconds when the block was mined. * @param difficultyTarget Number which this block hashes lower than. * @param nonce Arbitrary number to make the block hash lower than the target. - * @param transactions List of transactions including the coinbase. + * @param transactions List of transactions including the coinbase, or {@code null} for header-only blocks * @deprecated use {@link #Block(long, Sha256Hash, Sha256Hash, Instant, long, long, List)} */ @Deprecated public Block(long version, Sha256Hash prevBlockHash, Sha256Hash merkleRoot, long time, - long difficultyTarget, long nonce, List transactions) { + long difficultyTarget, long nonce, @Nullable List transactions) { this(version, prevBlockHash, merkleRoot, Instant.ofEpochSecond(time), difficultyTarget, nonce, transactions); }