Fix up after epic git history rebuild due to LFS issue

This commit is contained in:
catbref 2019-08-13 10:21:33 +01:00
parent fa0b7615a6
commit 8a0d93f304
2 changed files with 4 additions and 26 deletions

View File

@ -1,6 +1,6 @@
rootLogger.level = info rootLogger.level = info
# On Windows, uncomment this: # On Windows, uncomment this:
# property.dirname = ${sys:user.home}\\AppData\\Roaming\\MCF\\ # property.dirname = ${sys:user.home}\\AppData\\Roaming\\qora-core\\
property.filename = ${sys:log4j2.filenameTemplate:-log.txt} property.filename = ${sys:log4j2.filenameTemplate:-log.txt}
rootLogger.appenderRef.console.ref = stdout rootLogger.appenderRef.console.ref = stdout

View File

@ -207,10 +207,6 @@ public class Block {
byte[] reference = parentBlockData.getSignature(); byte[] reference = parentBlockData.getSignature();
BigDecimal generatingBalance = parentBlock.calcNextBlockGeneratingBalance(); BigDecimal generatingBalance = parentBlock.calcNextBlockGeneratingBalance();
// After a certain height, block timestamps are generated using previous block and generator's public key
if (height >= BlockChain.getInstance().getNewBlockTimestampHeight())
timestamp = calcTimestamp(parentBlockData, generator.getPublicKey());
byte[] generatorSignature; byte[] generatorSignature;
try { try {
generatorSignature = generator generatorSignature = generator
@ -259,13 +255,11 @@ public class Block {
*/ */
public Block regenerate(PrivateKeyAccount generator) throws DataException { public Block regenerate(PrivateKeyAccount generator) throws DataException {
Block newBlock = new Block(this.repository, this.blockData); Block newBlock = new Block(this.repository, this.blockData);
newBlock.generator = generator;
BlockData parentBlockData = this.getParent(); BlockData parentBlockData = this.getParent();
Block parentBlock = new Block(repository, parentBlockData); Block parentBlock = new Block(repository, parentBlockData);
newBlock.generator = generator;
BlockData parentBlockData = newBlock.getParent();
// Copy AT state data // Copy AT state data
newBlock.ourAtStates = this.ourAtStates; newBlock.ourAtStates = this.ourAtStates;
newBlock.atStates = newBlock.ourAtStates; newBlock.atStates = newBlock.ourAtStates;
@ -276,10 +270,6 @@ public class Block {
byte[] reference = this.blockData.getReference(); byte[] reference = this.blockData.getReference();
BigDecimal generatingBalance = this.blockData.getGeneratingBalance(); BigDecimal generatingBalance = this.blockData.getGeneratingBalance();
// After a certain height, block timestamps are generated using previous block and generator's public key
if (height >= BlockChain.getInstance().getNewBlockTimestampHeight())
timestamp = calcTimestamp(parentBlockData, generator.getPublicKey());
byte[] generatorSignature; byte[] generatorSignature;
try { try {
generatorSignature = generator generatorSignature = generator
@ -741,21 +731,15 @@ public class Block {
} }
/** /**
* Returns timestamp based on previous block and this block's generator. * Returns timestamp based on previous block.
* <p> * <p>
* For qora-core, we'll using the minimum from BlockChain config. * For qora-core, we'll using the minimum from BlockChain config.
*/ */
public static long calcTimestamp(BlockData parentBlockData, byte[] generatorPublicKey) { public static long calcMinimumTimestamp(BlockData parentBlockData) {
long minBlockTime = BlockChain.getInstance().getMinBlockTime(); // seconds long minBlockTime = BlockChain.getInstance().getMinBlockTime(); // seconds
return parentBlockData.getTimestamp() + (minBlockTime * 1000L); return parentBlockData.getTimestamp() + (minBlockTime * 1000L);
} }
public static long calcMinimumTimestamp(BlockData parentBlockData) {
final int thisHeight = parentBlockData.getHeight() + 1;
BlockTimingByHeight blockTiming = BlockChain.getInstance().getBlockTimingByHeight(thisHeight);
return parentBlockData.getTimestamp() + blockTiming.target - blockTiming.deviation;
}
/** /**
* Recalculate block's generator and transactions signatures, thus giving block full signature. * Recalculate block's generator and transactions signatures, thus giving block full signature.
* <p> * <p>
@ -824,12 +808,6 @@ public class Block {
// if (this.blockData.getTimestamp() < Block.calcMinimumTimestamp(parentBlockData)) // if (this.blockData.getTimestamp() < Block.calcMinimumTimestamp(parentBlockData))
// return ValidationResult.TIMESTAMP_TOO_SOON; // return ValidationResult.TIMESTAMP_TOO_SOON;
if (this.blockData.getHeight() >= BlockChain.getInstance().getNewBlockTimestampHeight()) {
long expectedTimestamp = calcTimestamp(parentBlockData, this.blockData.getGeneratorPublicKey());
if (this.blockData.getTimestamp() != expectedTimestamp)
return ValidationResult.TIMESTAMP_INCORRECT;
}
return ValidationResult.OK; return ValidationResult.OK;
} }