Merge pull request #51 from nicksavers/cleanup

Cleanup
This commit is contained in:
romanman 2014-07-02 19:25:19 +01:00
commit ac7c2c061e
4 changed files with 11 additions and 27 deletions

View File

@ -36,7 +36,7 @@ public class Block {
/* A scalar value equal to the mininum limit of gas expenditure per block */ /* A scalar value equal to the mininum limit of gas expenditure per block */
private static long MIN_GAS_LIMIT = 125000L; private static long MIN_GAS_LIMIT = 125000L;
public static BigInteger coinbaseReward = BigInteger.valueOf(1500000000000000000L); public static BigInteger BLOCK_REWARD = BigInteger.valueOf(1500000000000000000L);
private BlockHeader header; private BlockHeader header;

View File

@ -27,14 +27,12 @@ import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex; import org.spongycastle.util.encoders.Hex;
/** /**
*
* WorldManager is the main class to handle the processing of transactions and * WorldManager is the main class to handle the processing of transactions and
* managing the world state. * managing the world state.
* *
* www.ethereumJ.com * www.ethereumJ.com
* * @author: Roman Mandeleil
* @author: Roman Mandeleil Created on: 01/06/2014 10:44 * Created on: 01/06/2014 10:44
*
*/ */
public class WorldManager { public class WorldManager {
@ -48,9 +46,8 @@ public class WorldManager {
.synchronizedMap(new HashMap<String, Transaction>()); .synchronizedMap(new HashMap<String, Transaction>());
public DatabaseImpl chainDB = new DatabaseImpl("blockchain"); public DatabaseImpl chainDB = new DatabaseImpl("blockchain");
public Repository repository = new Repository(); public Repository repository = new Repository();
public static WorldManager instance = new WorldManager(); public static WorldManager instance = new WorldManager();
public WorldManager() { public WorldManager() {
@ -172,8 +169,7 @@ public class WorldManager {
if (tx.getValue() != null) { if (tx.getValue() != null) {
BigInteger senderBalance = repository.getBalance(senderAddress); BigInteger senderBalance = repository.getBalance(senderAddress);
BigInteger contractBalance = repository BigInteger contractBalance = repository.getBalance(contractAddress);
.getBalance(contractAddress);
if (senderBalance.compareTo(new BigInteger(1, tx.getValue())) >= 0) { if (senderBalance.compareTo(new BigInteger(1, tx.getValue())) >= 0) {
@ -302,7 +298,7 @@ public class WorldManager {
// miner reward // miner reward
if (repository.getAccountState(block.getCoinbase()) == null) if (repository.getAccountState(block.getCoinbase()) == null)
repository.createAccount(block.getCoinbase()); repository.createAccount(block.getCoinbase());
repository.addBalance(block.getCoinbase(), Block.coinbaseReward); repository.addBalance(block.getCoinbase(), Block.BLOCK_REWARD);
int i = 0; int i = 0;
List<Transaction> txList = block.getTransactionsList(); List<Transaction> txList = block.getTransactionsList();

View File

@ -2,6 +2,7 @@ package org.ethereum.core;
import org.ethereum.crypto.ECKey; import org.ethereum.crypto.ECKey;
import org.ethereum.crypto.HashUtil; import org.ethereum.crypto.HashUtil;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -19,7 +20,7 @@ import java.math.BigInteger;
public class WalletTest { public class WalletTest {
@Test @Test
public void SaveTest1() throws TransformerException, ParserConfigurationException { public void testSave1() throws TransformerException, ParserConfigurationException {
Wallet wallet = new Wallet(); Wallet wallet = new Wallet();
ECKey cowKey = ECKey.fromPrivate(HashUtil.sha3("cow".getBytes())); ECKey cowKey = ECKey.fromPrivate(HashUtil.sha3("cow".getBytes()));
@ -41,11 +42,11 @@ public class WalletTest {
} }
@Test @Test
public void LoadTest1() throws TransformerException, @Ignore
public void testLoad1() throws TransformerException,
ParserConfigurationException, IOException, SAXException { ParserConfigurationException, IOException, SAXException {
Wallet wallet = new Wallet(); Wallet wallet = new Wallet();
wallet.load(); wallet.load();
System.out.println();
} }
} }

View File

@ -127,18 +127,5 @@ public class MockDB implements DB {
*/ */
public int getAddedItems() { public int getAddedItems() {
return addedItems; return addedItems;
} }
// @Override
// public void forEach(Consumer<? super Entry<byte[], byte[]>> action) {
// TODO Auto-generated method stub
//
// }
// @Override
// public Spliterator<Entry<byte[], byte[]>> spliterator() {
// TODO Auto-generated method stub
// return null;
// }
} }