Merge pull request #28 from nicksavers/master
Fix BlockTest and added asserts for Block#1 calculations
This commit is contained in:
commit
970f978734
|
@ -7,7 +7,10 @@ import org.ethereum.util.ByteUtil;
|
|||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPElement;
|
||||
import org.ethereum.util.RLPList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongycastle.util.BigIntegers;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
|
@ -22,6 +25,8 @@ import java.util.List;
|
|||
*/
|
||||
public class Block {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(Block.class);
|
||||
|
||||
/* A scalar value equal to the mininum limit of gas expenditure per block */
|
||||
private static long MIN_GAS_LIMIT = BigInteger.valueOf(10).pow(4).longValue();
|
||||
|
||||
|
@ -44,6 +49,7 @@ public class Block {
|
|||
/* Constructors */
|
||||
|
||||
public Block(byte[] rawData) {
|
||||
logger.debug("RLP encoded [ " + Hex.toHexString(rawData) + " ]");
|
||||
this.rlpEncoded = rawData;
|
||||
this.parsed = false;
|
||||
}
|
||||
|
@ -91,7 +97,7 @@ public class Block {
|
|||
}
|
||||
|
||||
public Block getParent() {
|
||||
// TODO: Implement
|
||||
// TODO retrieve Parent from chain
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -141,7 +147,7 @@ public class Block {
|
|||
}
|
||||
|
||||
public boolean isGenesis() {
|
||||
return this.header.getNumber() == 0;
|
||||
return this.getNumber() == 0;
|
||||
}
|
||||
|
||||
public long getGasLimit() {
|
||||
|
@ -325,8 +331,8 @@ public class Block {
|
|||
return Genesis.DIFFICULTY;
|
||||
else {
|
||||
Block parent = this.getParent();
|
||||
long parentDifficulty = new BigInteger(1, parent.header.getDifficulty()).longValue();
|
||||
long newDifficulty = this.header.getTimestamp() >= parent.header.getTimestamp() + 42 ? parentDifficulty - (parentDifficulty >> 10) : (parentDifficulty + (parentDifficulty >> 10));
|
||||
long parentDifficulty = new BigInteger(1, parent.getDifficulty()).longValue();
|
||||
long newDifficulty = this.header.getTimestamp() >= parent.getTimestamp() + 42 ? parentDifficulty - (parentDifficulty >> 10) : (parentDifficulty + (parentDifficulty >> 10));
|
||||
return BigIntegers.asUnsignedByteArray(BigInteger.valueOf(newDifficulty));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.*;
|
|||
|
||||
public class Program {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger("VM");
|
||||
Logger logger = LoggerFactory.getLogger(Program.class);
|
||||
ProgramListener listener;
|
||||
|
||||
Stack<DataWord> stack = new Stack<DataWord>();
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue