mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 23:32:16 +00:00
Add another Block c'tor. Resolves issue 424.
This commit is contained in:
parent
4265e9c692
commit
1296074e8f
@ -30,6 +30,7 @@ import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.bitcoin.core.Utils.doubleDigest;
|
||||
@ -128,6 +129,32 @@ public class Block extends Message {
|
||||
super(params, payloadBytes, 0, parseLazy, parseRetain, length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a block initialized with all the given fields.
|
||||
* @param params Which network the block is for.
|
||||
* @param version This should usually be set to 1 or 2, depending on if the height is in the coinbase input.
|
||||
* @param prevBlockHash Reference to previous block in the chain or {@link Sha256Hash#ZERO_HASH} if genesis.
|
||||
* @param merkleRoot The root of the merkle tree formed by the transactions.
|
||||
* @param time UNIX 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.
|
||||
*/
|
||||
public Block(NetworkParameters params, long version, Sha256Hash prevBlockHash, Sha256Hash merkleRoot, long time,
|
||||
long difficultyTarget, long nonce, List<Transaction> transactions) {
|
||||
super(params);
|
||||
this.version = version;
|
||||
this.prevBlockHash = prevBlockHash;
|
||||
this.merkleRoot = merkleRoot;
|
||||
this.time = time;
|
||||
this.difficultyTarget = difficultyTarget;
|
||||
this.nonce = nonce;
|
||||
this.transactions = new LinkedList<Transaction>();
|
||||
this.transactions.addAll(transactions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>A utility method that calculates how much new Bitcoin would be created by the block at the given height.
|
||||
* The inflation of Bitcoin is predictable and drops roughly every 4 years (210,000 blocks). At the dawn of
|
||||
|
Loading…
Reference in New Issue
Block a user