Use long instead of hex for timestamp and difficulty
This commit is contained in:
parent
c02378563d
commit
bb2b8d7cb1
|
@ -188,6 +188,9 @@ public class Blockchain {
|
|||
|
||||
public void applyBlock(Block block) {
|
||||
|
||||
if(block.getNumber() == 1157)
|
||||
logger.debug("block 1157");
|
||||
|
||||
int i = 0;
|
||||
for (Transaction tx : block.getTransactionsList()) {
|
||||
stateLogger.debug("apply block: [ {} ] tx: [ {} ] ", block.getNumber(), i);
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ByteArrayWrapper implements Comparable<ByteArrayWrapper> {
|
|||
|
||||
public ByteArrayWrapper(byte[] data) {
|
||||
if (data == null) {
|
||||
throw new NullPointerException();
|
||||
throw new NullPointerException("Can't create a wrapper around null");
|
||||
}
|
||||
this.data = data;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package org.ethereum.db;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.ethereum.util.LRUMap;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
*
|
||||
|
@ -11,6 +13,9 @@ import java.util.Map;
|
|||
*/
|
||||
public class TrackDatabase implements Database {
|
||||
|
||||
// private static final int MAX_ENTRIES = 1000; // Should contain most commonly hashed values
|
||||
// private static LRUMap<ByteArrayWrapper, byte[]> valueCache = new LRUMap<>(0, MAX_ENTRIES);
|
||||
|
||||
private Database db;
|
||||
|
||||
private boolean trackingChanges;
|
||||
|
@ -43,21 +48,25 @@ public class TrackDatabase implements Database {
|
|||
}
|
||||
|
||||
public void put(byte[] key, byte[] value) {
|
||||
// valueCache.put(wKey, value);
|
||||
if (trackingChanges) {
|
||||
changes.put(new ByteArrayWrapper(key), value);
|
||||
ByteArrayWrapper wKey = new ByteArrayWrapper(key);
|
||||
changes.put(wKey, value);
|
||||
} else {
|
||||
db.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] get(byte[] key) {
|
||||
if(trackingChanges) {
|
||||
ByteArrayWrapper wKey = new ByteArrayWrapper(key);
|
||||
if(trackingChanges) {
|
||||
ByteArrayWrapper wKey = new ByteArrayWrapper(key);
|
||||
if (deletes.get(wKey) != null) return null;
|
||||
if (changes.get(wKey) != null) return changes.get(wKey);
|
||||
return db.get(key);
|
||||
}
|
||||
return db.get(key);
|
||||
// byte[] result = valueCache.get(wKey);
|
||||
// if(result != null)
|
||||
// return result;
|
||||
return db.get(key);
|
||||
}
|
||||
|
||||
/** Delete object (key) from db **/
|
||||
|
|
|
@ -34,7 +34,7 @@ public class StaticMessages {
|
|||
byte[] peerIdBytes = HashUtil.randomPeerId();
|
||||
|
||||
return new HelloMessage((byte) 0x17, (byte) 0x00,
|
||||
"EthereumJ [v0.5.1] by RomanJ", Byte.parseByte("00000111", 2),
|
||||
"EthereumJ/v0.5.1/Nick", Byte.parseByte("00000111", 2),
|
||||
(short) 30303, peerIdBytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class TrackTrie implements TrieFacade {
|
|||
for (ByteArrayWrapper key : changes.keySet()) {
|
||||
trie.update(key.getData(), changes.get(key));
|
||||
}
|
||||
// trie.sync();
|
||||
changes = null;
|
||||
trackingChanges = false;
|
||||
}
|
||||
|
@ -75,4 +76,10 @@ public class TrackTrie implements TrieFacade {
|
|||
trie.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,6 @@ public interface TrieFacade {
|
|||
public void update(byte[] key, byte[] value);
|
||||
public byte[] get(byte[] key);
|
||||
public void delete(byte[] key);
|
||||
|
||||
public void sync();
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ public class ProgramInvokeFactory {
|
|||
"timestamp={}\n" +
|
||||
"blockNumber={}\n" +
|
||||
"difficulty={}\n" +
|
||||
"gaslimit={}\n"
|
||||
,
|
||||
"gaslimit={}\n",
|
||||
|
||||
Hex.toHexString(address),
|
||||
Hex.toHexString(origin),
|
||||
|
@ -145,7 +144,7 @@ public class ProgramInvokeFactory {
|
|||
if (logger.isInfoEnabled()) {
|
||||
|
||||
|
||||
logger.info("Program invocation: \n" +
|
||||
logger.info("Internal call: \n" +
|
||||
"address={}\n" +
|
||||
"origin={}\n" +
|
||||
"caller={}\n" +
|
||||
|
@ -163,17 +162,17 @@ public class ProgramInvokeFactory {
|
|||
Hex.toHexString(address.getLast20Bytes()),
|
||||
Hex.toHexString(origin.getLast20Bytes()),
|
||||
Hex.toHexString(caller.getLast20Bytes()),
|
||||
new BigInteger(balance.getData()).longValue(),
|
||||
new BigInteger(gasPrice.getData()).longValue(),
|
||||
new BigInteger(gas.getData()).longValue(),
|
||||
Hex.toHexString(callValue.getData()),
|
||||
balance.longValue(),
|
||||
gasPrice.longValue(),
|
||||
gas.longValue(),
|
||||
callValue.longValue(),
|
||||
data == null ? "null": Hex.toHexString(data),
|
||||
Hex.toHexString(lastHash.getData()),
|
||||
Hex.toHexString(coinbase.getData()),
|
||||
Hex.toHexString(timestamp.getData()),
|
||||
new BigInteger(number.getData()).longValue(),
|
||||
Hex.toHexString(difficulty.getData()),
|
||||
new BigInteger(gasLimit.getData()).longValue());
|
||||
Hex.toHexString(coinbase.getLast20Bytes()),
|
||||
timestamp.longValue(),
|
||||
number.longValue(),
|
||||
difficulty.longValue(),
|
||||
gasLimit.longValue());
|
||||
}
|
||||
|
||||
return new ProgramInvokeImpl(address, origin, caller, balance, gasPrice, gas, callValue,
|
||||
|
|
|
@ -24,7 +24,7 @@ log4j.logger.wire = ERROR
|
|||
log4j.logger.VM = DEBUG
|
||||
log4j.logger.main = INFO
|
||||
log4j.logger.state = DEBUG
|
||||
log4j.logger.repository = DEBUG
|
||||
log4j.logger.repository = INFO
|
||||
log4j.logger.blockchain = INFO
|
||||
log4j.logger.ui = ERROR
|
||||
log4j.logger.gas = ERROR
|
||||
|
|
|
@ -81,7 +81,7 @@ samples.dir = samples
|
|||
# the existing database will be
|
||||
# destroyed and all the data will be
|
||||
# downloaded from peers again
|
||||
database.reset = true
|
||||
database.reset = false
|
||||
|
||||
# place to save physical storage files
|
||||
database.dir = database
|
||||
|
|
Loading…
Reference in New Issue