mirror of
https://github.com/Qortal/qortal.git
synced 2025-04-23 11:27:51 +00:00
* Code added for calculating an account's generating balance. (CIYAM AT support yet to be added). * Added associated code in Block for calculating next block's timestamp, generating balance, base target, etc. * ValidationResult enum added to Block, mostly to aid debugging. * Block.isValid() now returns ValidationResult instead of boolean. * Block.isValid() now has added proof-of-stake tests. * Some blockchain-related constants, like feature release heights/timestamps, moved from Block to BlockChain. * Added better Block constructor for use when creating a new block. * Added helpful 'navigation' methods to Block to get to block's parent (or child). * Changed visibility of block's individual signature calculators to protected, in favour of public sign() method. * Added asset existence check to Payment.isValid. * All current transaction objects (qora.transaction.*) now have private subclassed transaction variable to save multiple casts in various methods. * Also added to above: * isInvolved(Account) : boolean * getRecipients() : List<Account> * getAmount(Account) : BigDecimal * Added BlockRepository.getLastBlock() to fetch highest block in blockchain. * Added diagnostics to HSQLDBRepository.close() to alert if there are any uncommitted changes during closure. (Currently under suspicion due to possible HSQLDB bug!) * Old "TransactionTests" renamed to "SerializationTests" as that's what they really are. * New "TransactionTests" added to test processing of transactions. (Currently only a PaymentTransaction). * PaymentTransformer.toBytes() detects and skips null signature. This was causing issues with Transaction.toBytesLessSignature(). Needs rolling out to other transaction types if acceptable.
125 lines
2.9 KiB
Java
125 lines
2.9 KiB
Java
package data.block;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import com.google.common.primitives.Bytes;
|
|
|
|
public class BlockData {
|
|
|
|
private byte[] signature;
|
|
private int version;
|
|
private byte[] reference;
|
|
private int transactionCount;
|
|
private BigDecimal totalFees;
|
|
private byte[] transactionsSignature;
|
|
private int height;
|
|
private long timestamp;
|
|
private BigDecimal generatingBalance;
|
|
private byte[] generatorPublicKey;
|
|
private byte[] generatorSignature;
|
|
private byte[] atBytes;
|
|
private BigDecimal atFees;
|
|
|
|
public BlockData(int version, byte[] reference, int transactionCount, BigDecimal totalFees, byte[] transactionsSignature, int height, long timestamp,
|
|
BigDecimal generatingBalance, byte[] generatorPublicKey, byte[] generatorSignature, byte[] atBytes, BigDecimal atFees) {
|
|
this.version = version;
|
|
this.reference = reference;
|
|
this.transactionCount = transactionCount;
|
|
this.totalFees = totalFees;
|
|
this.transactionsSignature = transactionsSignature;
|
|
this.height = height;
|
|
this.timestamp = timestamp;
|
|
this.generatingBalance = generatingBalance;
|
|
this.generatorPublicKey = generatorPublicKey;
|
|
this.generatorSignature = generatorSignature;
|
|
this.atBytes = atBytes;
|
|
this.atFees = atFees;
|
|
|
|
if (this.generatorSignature != null && this.transactionsSignature != null)
|
|
this.signature = Bytes.concat(this.generatorSignature, this.transactionsSignature);
|
|
else
|
|
this.signature = null;
|
|
}
|
|
|
|
public int getTransactionCount() {
|
|
return this.transactionCount;
|
|
}
|
|
|
|
public void setTransactionCount(int transactionCount) {
|
|
this.transactionCount = transactionCount;
|
|
}
|
|
|
|
public BigDecimal getTotalFees() {
|
|
return this.totalFees;
|
|
}
|
|
|
|
public void setTotalFees(BigDecimal totalFees) {
|
|
this.totalFees = totalFees;
|
|
}
|
|
|
|
public byte[] getTransactionsSignature() {
|
|
return this.transactionsSignature;
|
|
}
|
|
|
|
public void setTransactionsSignature(byte[] transactionsSignature) {
|
|
this.transactionsSignature = transactionsSignature;
|
|
}
|
|
|
|
public byte[] getSignature() {
|
|
return this.signature;
|
|
}
|
|
|
|
public void setSignature(byte[] signature) {
|
|
this.signature = signature;
|
|
}
|
|
|
|
public int getVersion() {
|
|
return this.version;
|
|
}
|
|
|
|
public byte[] getReference() {
|
|
return this.reference;
|
|
}
|
|
|
|
public void setReference(byte[] reference) {
|
|
this.reference = reference;
|
|
}
|
|
|
|
public int getHeight() {
|
|
return this.height;
|
|
}
|
|
|
|
public void setHeight(int height) {
|
|
this.height = height;
|
|
}
|
|
|
|
public long getTimestamp() {
|
|
return this.timestamp;
|
|
}
|
|
|
|
public BigDecimal getGeneratingBalance() {
|
|
return this.generatingBalance;
|
|
}
|
|
|
|
public byte[] getGeneratorPublicKey() {
|
|
return this.generatorPublicKey;
|
|
}
|
|
|
|
public byte[] getGeneratorSignature() {
|
|
return this.generatorSignature;
|
|
}
|
|
|
|
public void setGeneratorSignature(byte[] generatorSignature) {
|
|
this.generatorSignature = generatorSignature;
|
|
}
|
|
|
|
public byte[] getAtBytes() {
|
|
return this.atBytes;
|
|
}
|
|
|
|
public BigDecimal getAtFees() {
|
|
return this.atFees;
|
|
}
|
|
|
|
}
|