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