mirror of
https://github.com/status-im/ethereumj-personal.git
synced 2025-01-20 16:59:17 +00:00
fix some typos and do some cleanup
This commit is contained in:
parent
e56dfacaae
commit
15971ed797
@ -60,7 +60,7 @@ import static org.ethereum.core.Denomination.SZABO;
|
||||
@Component
|
||||
public class BlockchainImpl implements Blockchain {
|
||||
|
||||
/* A scalar value equal to the mininum limit of gas expenditure per block */
|
||||
/* A scalar value equal to the minimum limit of gas expenditure per block */
|
||||
private static long MIN_GAS_LIMIT = 125000L;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("blockchain");
|
||||
|
@ -128,7 +128,7 @@ public class BlockStoreImpl implements BlockStore{
|
||||
public BigInteger getTotalDifficultySince(long number) {
|
||||
|
||||
BigInteger result = (BigInteger) sessionFactory.getCurrentSession().
|
||||
createQuery("select sum(cummulativeDifficulty) from BlockVO where number > :number").
|
||||
createQuery("select sum(cumulativeDifficulty) from BlockVO where number > :number").
|
||||
setParameter("number", number).
|
||||
uniqueResult();
|
||||
|
||||
@ -141,7 +141,7 @@ public class BlockStoreImpl implements BlockStore{
|
||||
public BigInteger getTotalDifficulty() {
|
||||
|
||||
BigInteger result = (BigInteger) sessionFactory.getCurrentSession().
|
||||
createQuery("select sum(cummulativeDifficulty) from BlockVO").uniqueResult();
|
||||
createQuery("select sum(cumulativeDifficulty) from BlockVO").uniqueResult();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -23,16 +23,16 @@ public class BlockVO {
|
||||
@Lob
|
||||
byte[] rlp;
|
||||
|
||||
BigInteger cummulativeDifficulty;
|
||||
BigInteger cumulativeDifficulty;
|
||||
|
||||
public BlockVO() {
|
||||
}
|
||||
|
||||
public BlockVO(Long number, byte[] hash, byte[] rlp, BigInteger cummulativeDifficulty) {
|
||||
public BlockVO(Long number, byte[] hash, byte[] rlp, BigInteger cumulativeDifficulty) {
|
||||
this.number = number;
|
||||
this.hash = hash;
|
||||
this.rlp = rlp;
|
||||
this.cummulativeDifficulty = cummulativeDifficulty;
|
||||
this.cumulativeDifficulty = cumulativeDifficulty;
|
||||
}
|
||||
|
||||
public byte[] getHash() {
|
||||
@ -59,11 +59,11 @@ public class BlockVO {
|
||||
this.rlp = rlp;
|
||||
}
|
||||
|
||||
public BigInteger getCummulativeDifficulty() {
|
||||
return cummulativeDifficulty;
|
||||
public BigInteger getCumulativeDifficulty() {
|
||||
return cumulativeDifficulty;
|
||||
}
|
||||
|
||||
public void setCummulativeDifficulty(BigInteger cummulativeDifficulty) {
|
||||
this.cummulativeDifficulty = cummulativeDifficulty;
|
||||
public void setCumulativeDifficulty(BigInteger cumulativeDifficulty) {
|
||||
this.cumulativeDifficulty = cumulativeDifficulty;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public interface Ethereum {
|
||||
* @param gasPrice - gas price bid by miner , the user ask can be based on
|
||||
* lastr submited block
|
||||
* @param gas - the quantity of gas requested for the transaction
|
||||
* @param recieveAddress - the target address of the transaction
|
||||
* @param receiveAddress - the target address of the transaction
|
||||
* @param value - the ether value of the transaction
|
||||
* @param data - can be init procedure for creational transaction,
|
||||
* also msg data for invoke transaction for only value
|
||||
@ -102,7 +102,7 @@ public interface Ethereum {
|
||||
public Transaction createTransaction(BigInteger nonce,
|
||||
BigInteger gasPrice,
|
||||
BigInteger gas,
|
||||
byte[] recieveAddress,
|
||||
byte[] receiveAddress,
|
||||
BigInteger value, byte[] data);
|
||||
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class EthereumImpl implements Ethereum {
|
||||
public Transaction createTransaction(BigInteger nonce,
|
||||
BigInteger gasPrice,
|
||||
BigInteger gas,
|
||||
byte[] recieveAddress,
|
||||
byte[] receiveAddress,
|
||||
BigInteger value, byte[] data) {
|
||||
|
||||
byte[] nonceBytes = ByteUtil.bigIntegerToBytes(nonce);
|
||||
@ -210,7 +210,7 @@ public class EthereumImpl implements Ethereum {
|
||||
byte[] valueBytes = ByteUtil.bigIntegerToBytes(value);
|
||||
|
||||
Transaction tx = new Transaction(nonceBytes, gasPriceBytes, gasBytes,
|
||||
recieveAddress, valueBytes, data);
|
||||
receiveAddress, valueBytes, data);
|
||||
|
||||
return tx;
|
||||
}
|
||||
|
@ -99,24 +99,24 @@ public class AccountState {
|
||||
|
||||
BigInteger expectedBalance = new BigInteger(1, this.getBalance());
|
||||
if (!state.getBalance().equals(expectedBalance)) {
|
||||
String formatedString = String.format("Account: %s: has unexpected balance, expected balance: %s found balance: %s",
|
||||
String formattedString = String.format("Account: %s: has unexpected balance, expected balance: %s found balance: %s",
|
||||
Hex.toHexString(this.address), expectedBalance.toString(), state.getBalance().toString());
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
|
||||
BigInteger expectedNonce = new BigInteger(1, this.getNonce());
|
||||
if (!state.getNonce().equals(expectedNonce)) {
|
||||
state.getNonce();
|
||||
this.getNonce();
|
||||
String formatedString = String.format("Account: %s: has unexpected nonce, expected nonce: %s found nonce: %s",
|
||||
String formattedString = String.format("Account: %s: has unexpected nonce, expected nonce: %s found nonce: %s",
|
||||
Hex.toHexString(this.address), expectedNonce.toString(), state.getNonce().toString());
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
|
||||
if (!Arrays.equals(details.getCode(),this.getCode())) {
|
||||
String formatedString = String.format("Account: %s: has unexpected nonce, expected nonce: %s found nonce: %s",
|
||||
String formattedString = String.format("Account: %s: has unexpected nonce, expected nonce: %s found nonce: %s",
|
||||
Hex.toHexString(this.address), Hex.toHexString(this.getCode()), Hex.toHexString(details.getCode()));
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
|
||||
|
||||
@ -131,22 +131,22 @@ public class AccountState {
|
||||
DataWord expectedValue = this.getStorage().get(key);
|
||||
if (expectedValue == null) {
|
||||
|
||||
String formatedString = String.format("Account: %s: has unexpected storage data: %s = %s",
|
||||
String formattedString = String.format("Account: %s: has unexpected storage data: %s = %s",
|
||||
Hex.toHexString(this.address),
|
||||
key.toString(),
|
||||
value.toString());
|
||||
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!expectedValue.equals(value)) {
|
||||
|
||||
String formatedString = String.format("Account: %s: has unexpected value, for key: %s , expectedValue: %s real value: %s",
|
||||
String formattedString = String.format("Account: %s: has unexpected value, for key: %s , expectedValue: %s real value: %s",
|
||||
Hex.toHexString(this.address), key.toString(),
|
||||
expectedValue.toString(), value.toString());
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -155,9 +155,9 @@ public class AccountState {
|
||||
|
||||
for (DataWord key : expectedKeys) {
|
||||
if (!checked.contains(key)) {
|
||||
String formatedString = String.format("Account: %s: doesn't exist expected storage key: %s",
|
||||
String formattedString = String.format("Account: %s: doesn't exist expected storage key: %s",
|
||||
Hex.toHexString(this.address), key.toString());
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import java.math.BigInteger;
|
||||
public class Env {
|
||||
|
||||
private byte[] currentCoinbase;
|
||||
private byte[] currentDifficlty;
|
||||
private byte[] currentDifficulty;
|
||||
private byte[] currentGasLimit;
|
||||
private byte[] currentNumber;
|
||||
private byte[] currentTimestamp;
|
||||
@ -39,7 +39,7 @@ public class Env {
|
||||
String prevHash = env.get("previousHash").toString();
|
||||
|
||||
this.currentCoinbase = Hex.decode(coinbase);
|
||||
this.currentDifficlty = new BigInteger(difficulty).toByteArray();
|
||||
this.currentDifficulty = new BigInteger(difficulty).toByteArray();
|
||||
this.currentGasLimit = new BigInteger(gasLimit).toByteArray();
|
||||
this.currentNumber = new BigInteger(number).toByteArray();
|
||||
this.currentTimestamp = new BigInteger(timestamp).toByteArray();
|
||||
@ -51,8 +51,8 @@ public class Env {
|
||||
return currentCoinbase;
|
||||
}
|
||||
|
||||
public byte[] getCurrentDifficlty() {
|
||||
return currentDifficlty;
|
||||
public byte[] getCurrentDifficulty() {
|
||||
return currentDifficulty;
|
||||
}
|
||||
|
||||
public byte[] getCurrentGasLimit() {
|
||||
@ -75,7 +75,7 @@ public class Env {
|
||||
public String toString() {
|
||||
return "Env{" +
|
||||
"currentCoinbase=" + Hex.toHexString(currentCoinbase) +
|
||||
", currentDifficlty=" + Hex.toHexString(currentDifficlty) +
|
||||
", currentDifficulty=" + Hex.toHexString(currentDifficulty) +
|
||||
", currentGasLimit=" + Hex.toHexString(currentGasLimit) +
|
||||
", currentNumber=" + Hex.toHexString(currentNumber) +
|
||||
", currentTimestamp=" + Hex.toHexString(currentTimestamp) +
|
||||
|
@ -56,9 +56,9 @@ public class Logs {
|
||||
|
||||
if (!postAddress.equals(realAddress)) {
|
||||
|
||||
String formatedString = String.format("Log: %s: has unexpected address, expected address: %s found address: %s",
|
||||
String formattedString = String.format("Log: %s: has unexpected address, expected address: %s found address: %s",
|
||||
i, postAddress, realAddress);
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
|
||||
String postData = Hex.toHexString(postLog.getData());
|
||||
@ -66,9 +66,9 @@ public class Logs {
|
||||
|
||||
if (!postData.equals(realData)) {
|
||||
|
||||
String formatedString = String.format("Log: %s: has unexpected data, expected data: %s found data: %s",
|
||||
String formattedString = String.format("Log: %s: has unexpected data, expected data: %s found data: %s",
|
||||
i, postData, realData);
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
|
||||
String postBloom = Hex.toHexString(postLog.getBloom().getData());
|
||||
@ -76,9 +76,9 @@ public class Logs {
|
||||
|
||||
if (!postData.equals(realData)){
|
||||
|
||||
String formatedString = String.format("Log: %s: has unexpected bloom, expected bloom: %s found bloom: %s",
|
||||
String formattedString = String.format("Log: %s: has unexpected bloom, expected bloom: %s found bloom: %s",
|
||||
i, postBloom, realBloom);
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
|
||||
List<DataWord> postTopics = postLog.getTopics();
|
||||
@ -91,9 +91,9 @@ public class Logs {
|
||||
|
||||
if (!postTopic.equals(realTopic)) {
|
||||
|
||||
String formatedString = String.format("Log: %s: has unexpected topic: %s, expected topic: %s found topic: %s",
|
||||
String formattedString = String.format("Log: %s: has unexpected topic: %s, expected topic: %s found topic: %s",
|
||||
i, j, postTopic, realTopic);
|
||||
results.add(formatedString);
|
||||
results.add(formattedString);
|
||||
}
|
||||
++j;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class TestProgramInvokeFactory implements ProgramInvokeFactory {
|
||||
long number = ByteUtil.byteArrayToLong(env.getCurrentNumber());
|
||||
|
||||
/*** DIFFICULTY op ***/
|
||||
byte[] difficulty = env.getCurrentDifficlty();
|
||||
byte[] difficulty = env.getCurrentDifficulty();
|
||||
|
||||
/*** GASLIMIT op ***/
|
||||
long gaslimit = ByteUtil.byteArrayToLong(env.getCurrentGasLimit());
|
||||
|
@ -173,7 +173,7 @@ public class TestRunner {
|
||||
byte[] coinbase = env.getCurrentCoinbase();
|
||||
long timestamp = new BigInteger(env.getCurrentTimestamp()).longValue();
|
||||
long number = new BigInteger(env.getCurrentNumber()).longValue();
|
||||
byte[] difficulty = env.getCurrentDifficlty();
|
||||
byte[] difficulty = env.getCurrentDifficulty();
|
||||
long gaslimit = new BigInteger(env.getCurrentGasLimit()).longValue();
|
||||
|
||||
// Origin and caller need to exist in order to be able to execute
|
||||
|
@ -76,7 +76,7 @@ public class PeerServer {
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.debug("Exception: {} ({})", e.getMessage(), e.getClass().getName());
|
||||
throw new Error("Server Disconnnected");
|
||||
throw new Error("Server Disconnected");
|
||||
} finally {
|
||||
workerGroup.shutdownGracefully();
|
||||
|
||||
|
@ -733,7 +733,7 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getMsgOutputArraySize(String code) {
|
||||
private static Integer getMsgOutputArraySize(String code) {
|
||||
|
||||
String result = "0";
|
||||
Pattern pattern = Pattern.compile("<out_size ([0-9])* out_size>");
|
||||
@ -746,7 +746,7 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
|
||||
return Integer.parseInt(result);
|
||||
}
|
||||
|
||||
private Integer getMsgInputArraySize(String code) {
|
||||
private static Integer getMsgInputArraySize(String code) {
|
||||
|
||||
String result = "0";
|
||||
Pattern pattern = Pattern.compile("<in_size ([0-9])* in_size>");
|
||||
@ -759,14 +759,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
|
||||
return Integer.parseInt(result);
|
||||
}
|
||||
|
||||
private String cleanMsgString(String code) {
|
||||
|
||||
String result = "";
|
||||
|
||||
Pattern pattern = Pattern.compile("<(.*?)>");
|
||||
result = code.replaceAll("<(.*?)>", "");
|
||||
|
||||
return result;
|
||||
private static String cleanMsgString(String code) {
|
||||
return code.replaceAll("<(.*?)>", "");
|
||||
}
|
||||
|
||||
|
||||
@ -774,7 +768,7 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
|
||||
* After the array deff code is set
|
||||
* extract the size out of code string
|
||||
*/
|
||||
private Integer getArraySize(String code) {
|
||||
private static Integer getArraySize(String code) {
|
||||
|
||||
String result = "0";
|
||||
Pattern pattern = Pattern.compile(" [0-9]* SWAP MSTORE$");
|
||||
|
@ -107,7 +107,7 @@ public class TrieImpl implements Trie {
|
||||
byte[] k = binToNibbles(key);
|
||||
Value c = new Value(this.get(this.root, k));
|
||||
|
||||
return (c == null) ? null : c.asBytes();
|
||||
return c.asBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,7 +414,7 @@ public class TrieImpl implements Trie {
|
||||
*******************************/
|
||||
|
||||
// Created an array of empty elements of required length
|
||||
private Object[] emptyStringSlice(int l) {
|
||||
private static Object[] emptyStringSlice(int l) {
|
||||
Object[] slice = new Object[l];
|
||||
for (int i = 0; i < l; i++) {
|
||||
slice[i] = "";
|
||||
@ -484,10 +484,10 @@ public class TrieImpl implements Trie {
|
||||
|
||||
public String getTrieDump() {
|
||||
|
||||
String root = "";
|
||||
TraceAllNodes traceAction = new TraceAllNodes();
|
||||
this.scanTree(this.getRootHash(), traceAction);
|
||||
|
||||
final String root;
|
||||
if (this.getRoot() instanceof Value) {
|
||||
root = "root: " + Hex.toHexString(getRootHash()) + " => " + this.getRoot() + "\n";
|
||||
} else {
|
||||
@ -501,10 +501,6 @@ public class TrieImpl implements Trie {
|
||||
}
|
||||
|
||||
public boolean validate() {
|
||||
|
||||
if (cache.get(getRootHash()) != null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return cache.get(getRootHash()) != null;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class TrieIterator {
|
||||
if (currentNode.length() == 2) {
|
||||
byte[] k = unpackToNibbles(currentNode.get(0).asBytes());
|
||||
|
||||
if (currentNode.get(1).asString() == "") {
|
||||
if (currentNode.get(1).asString().isEmpty()) {
|
||||
this.workNode(currentNode.get(1));
|
||||
} else {
|
||||
if (k[k.length - 1] == 16) {
|
||||
@ -44,11 +44,11 @@ public class TrieIterator {
|
||||
if (i == 16 && currentNode.get(i).length() != 0) {
|
||||
this.values.add(currentNode.get(i).asString());
|
||||
} else {
|
||||
if (currentNode.get(i).asString() == "") {
|
||||
if (currentNode.get(i).asString().isEmpty()) {
|
||||
this.workNode(currentNode.get(i));
|
||||
} else {
|
||||
String val = currentNode.get(i).asString();
|
||||
if (val != "") {
|
||||
if (!val.isEmpty()) {
|
||||
this.shas.add(currentNode.get(1).asBytes());
|
||||
this.getNode(val.getBytes());
|
||||
}
|
||||
|
@ -230,8 +230,7 @@ public class RLP {
|
||||
|
||||
public static BigInteger decodeBigInteger(byte[] data, int index) {
|
||||
|
||||
BigInteger value = null;
|
||||
int length = 0;
|
||||
final int length;
|
||||
|
||||
if ((data[index] & 0xFF) >= OFFSET_LONG_ITEM
|
||||
&& (data[index] & 0xFF) < OFFSET_SHORT_LIST) {
|
||||
@ -249,14 +248,12 @@ public class RLP {
|
||||
}
|
||||
byte[] valueBytes = new byte[length];
|
||||
System.arraycopy(data, index, valueBytes, 0, length);
|
||||
value = new BigInteger(1, valueBytes);
|
||||
return value;
|
||||
return new BigInteger(1, valueBytes);
|
||||
}
|
||||
|
||||
private static byte[] decodeByteArray(byte[] data, int index) {
|
||||
|
||||
byte[] value = null;
|
||||
int length = 0;
|
||||
final int length;
|
||||
|
||||
if ((data[index] & 0xFF) >= OFFSET_LONG_ITEM
|
||||
&& (data[index] & 0xFF) < OFFSET_SHORT_LIST) {
|
||||
@ -274,8 +271,7 @@ public class RLP {
|
||||
}
|
||||
byte[] valueBytes = new byte[length];
|
||||
System.arraycopy(data, index, valueBytes, 0, length);
|
||||
value = valueBytes;
|
||||
return value;
|
||||
return valueBytes;
|
||||
}
|
||||
|
||||
private static int nextItemLength(byte[] data, int index) {
|
||||
@ -286,32 +282,25 @@ public class RLP {
|
||||
if ((data[index] & 0xFF) >= OFFSET_LONG_LIST) {
|
||||
byte lengthOfLength = (byte) (data[index] - OFFSET_LONG_LIST);
|
||||
|
||||
int length = calcLength(lengthOfLength, data, index);
|
||||
return length;
|
||||
return calcLength(lengthOfLength, data, index);
|
||||
}
|
||||
if ((data[index] & 0xFF) >= OFFSET_SHORT_LIST
|
||||
&& (data[index] & 0xFF) < OFFSET_LONG_LIST) {
|
||||
|
||||
byte length = (byte) ((data[index] & 0xFF) - OFFSET_SHORT_LIST);
|
||||
return length;
|
||||
return (byte) ((data[index] & 0xFF) - OFFSET_SHORT_LIST);
|
||||
}
|
||||
if ((data[index] & 0xFF) > OFFSET_LONG_ITEM
|
||||
&& (data[index] & 0xFF) < OFFSET_SHORT_LIST) {
|
||||
|
||||
byte lengthOfLength = (byte) (data[index] - OFFSET_LONG_ITEM);
|
||||
int length = calcLength(lengthOfLength, data, index);
|
||||
return length;
|
||||
return calcLength(lengthOfLength, data, index);
|
||||
}
|
||||
if ((data[index] & 0xFF) > OFFSET_SHORT_ITEM
|
||||
&& (data[index] & 0xFF) <= OFFSET_LONG_ITEM) {
|
||||
return (byte) ((data[index] & 0xFF) - OFFSET_SHORT_ITEM);
|
||||
}
|
||||
|
||||
byte length = (byte) ((data[index] & 0xFF) - OFFSET_SHORT_ITEM);
|
||||
return length;
|
||||
}
|
||||
if ((data[index] & 0xFF) == OFFSET_SHORT_ITEM) {
|
||||
return 1;
|
||||
}
|
||||
if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {
|
||||
if ((data[index] & 0xFF) <= OFFSET_SHORT_ITEM) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
@ -409,7 +398,7 @@ public class RLP {
|
||||
* Get exactly one message payload
|
||||
*/
|
||||
public static void fullTraverse(byte[] msgData, int level, int startPos,
|
||||
int endPos, int levelToIndex, Queue<Integer> index) {
|
||||
int endPos, int levelToIndex, Queue<Integer> index) {
|
||||
|
||||
try {
|
||||
|
||||
@ -535,10 +524,9 @@ public class RLP {
|
||||
/**
|
||||
* Parse wire byte[] message into RLP elements
|
||||
*
|
||||
* @param msgData
|
||||
* - raw RLP data
|
||||
* @param msgData - raw RLP data
|
||||
* @return rlpList
|
||||
* - outcome of recursive RLP structure
|
||||
* - outcome of recursive RLP structure
|
||||
*/
|
||||
public static RLPList decode2(byte[] msgData) {
|
||||
RLPList rlpList = new RLPList();
|
||||
@ -550,7 +538,7 @@ public class RLP {
|
||||
* Get exactly one message payload
|
||||
*/
|
||||
private static void fullTraverse(byte[] msgData, int level, int startPos,
|
||||
int endPos, int levelToIndex, RLPList rlpList) {
|
||||
int endPos, int levelToIndex, RLPList rlpList) {
|
||||
|
||||
try {
|
||||
if (msgData == null || msgData.length == 0)
|
||||
@ -672,7 +660,7 @@ public class RLP {
|
||||
* Reads any RLP encoded byte-array and returns all objects as byte-array or list of byte-arrays
|
||||
*
|
||||
* @param data RLP encoded byte-array
|
||||
* @param pos position in the array to start reading
|
||||
* @param pos position in the array to start reading
|
||||
* @return DecodeResult encapsulates the decoded items as a single Object and the final read position
|
||||
*/
|
||||
public static DecodeResult decode(byte[] data, int pos) {
|
||||
@ -871,8 +859,7 @@ public class RLP {
|
||||
}
|
||||
|
||||
int totalLength = 0;
|
||||
for (int i = 0;
|
||||
elements != null && i < elements.length; ++i) {
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
totalLength += elements[i].length;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class Utils {
|
||||
public static String hexStringToDecimalString(String hexNum) {
|
||||
|
||||
boolean match = Pattern.matches("0[xX][0-9a-fA-F]+", hexNum);
|
||||
if (!match) throw new Error("The string doesn't conains hex num in form 0x.. : [" + hexNum + "]");
|
||||
if (!match) throw new Error("The string doesn't contains hex num in form 0x.. : [" + hexNum + "]");
|
||||
|
||||
byte[] numberBytes = Hex.decode(hexNum.substring(2));
|
||||
return (new BigInteger(1, numberBytes)).toString();
|
||||
@ -73,7 +73,7 @@ public class Utils {
|
||||
* @return - decode and validated address byte[]
|
||||
*/
|
||||
public static byte[] addressStringToBytes(String hex) {
|
||||
byte[] addr = null;
|
||||
final byte[] addr;
|
||||
try {
|
||||
addr = Hex.decode(hex);
|
||||
} catch (DecoderException addressIsNotValid) {
|
||||
|
@ -160,10 +160,7 @@ public class Value {
|
||||
if (aData > 32 && aData < 126) ++readableChars;
|
||||
}
|
||||
|
||||
if ((double) readableChars / (double) data.length > 0.55)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (double) readableChars / (double) data.length > 0.55;
|
||||
}
|
||||
|
||||
// it's only if the isBytes() = true;
|
||||
@ -179,10 +176,7 @@ public class Value {
|
||||
++hexChars;
|
||||
}
|
||||
|
||||
if ((double) hexChars / (double) data.length > 0.9)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (double) hexChars / (double) data.length > 0.9;
|
||||
}
|
||||
|
||||
public boolean isHashCode() {
|
||||
|
@ -9,7 +9,7 @@ public class MessageCall {
|
||||
public enum MsgType {
|
||||
CALL,
|
||||
STATELESS,
|
||||
POST;
|
||||
POST
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -596,9 +596,8 @@ public class Program {
|
||||
if (invokeData == null) return DataWord.ZERO_EMPTY_ARRAY;
|
||||
|
||||
BigInteger balance = result.getRepository().getBalance(address.getLast20Bytes());
|
||||
DataWord balanceData = new DataWord(balance.toByteArray());
|
||||
|
||||
return balanceData;
|
||||
return new DataWord(balance.toByteArray());
|
||||
}
|
||||
|
||||
public DataWord getOriginAddress() {
|
||||
@ -905,7 +904,7 @@ public class Program {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void vallidateJumpDest(int nextPC) {
|
||||
public void validateJumpDest(int nextPC) {
|
||||
if (!jumpdest.contains(nextPC)) throw new BadJumpDestinationException();
|
||||
}
|
||||
|
||||
|
@ -119,12 +119,9 @@ public class ProgramInvokeFactoryImpl implements ProgramInvokeFactory {
|
||||
gaslimit);
|
||||
}
|
||||
|
||||
ProgramInvoke programInvoke =
|
||||
new ProgramInvokeImpl(address, origin, caller, balance, gasPrice, gas, callValue, data,
|
||||
lastHash, coinbase, timestamp, number, difficulty, gaslimit,
|
||||
repository, blockStore);
|
||||
|
||||
return programInvoke;
|
||||
return new ProgramInvokeImpl(address, origin, caller, balance, gasPrice, gas, callValue, data,
|
||||
lastHash, coinbase, timestamp, number, difficulty, gaslimit,
|
||||
repository, blockStore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -504,7 +504,7 @@ public class VM {
|
||||
case BYTE: {
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
DataWord result = null;
|
||||
final DataWord result;
|
||||
if (word1.value().compareTo(_32_) == -1) {
|
||||
byte tmp = word2.getData()[word1.intValue()];
|
||||
word2.and(DataWord.ZERO);
|
||||
@ -896,7 +896,7 @@ public class VM {
|
||||
case JUMP: {
|
||||
DataWord pos = program.stackPop();
|
||||
int nextPC = pos.intValue(); // possible overflow
|
||||
program.vallidateJumpDest(nextPC);
|
||||
program.validateJumpDest(nextPC);
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
hint = "~> " + nextPC;
|
||||
@ -912,7 +912,7 @@ public class VM {
|
||||
if (!cond.isZero()) {
|
||||
|
||||
int nextPC = pos.intValue(); // possible overflow
|
||||
program.vallidateJumpDest(nextPC);
|
||||
program.validateJumpDest(nextPC);
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
hint = "~> " + nextPC;
|
||||
|
Loading…
x
Reference in New Issue
Block a user