Public method to get repository

This commit is contained in:
nicksavers 2014-07-02 15:33:41 +02:00
parent 504a7e139f
commit 4037dc40c8
4 changed files with 14 additions and 11 deletions

View File

@ -71,7 +71,7 @@ public class Block {
timestamp, extraData, nonce);
this.txsState = new Trie(null);
byte[] stateRoot = WorldManager.instance.repository.getRootHash();
byte[] stateRoot = WorldManager.instance.getRepository().getRootHash();
this.header.setStateRoot(stateRoot);
this.header.setTxTrieRoot(txsState.getRootHash());

View File

@ -67,15 +67,15 @@ public class Genesis extends Block {
// The proof-of-concept series include a development premine, making the state root hash
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
for (String address : premine) {
WorldManager.instance.repository.createAccount(Hex.decode(address));
WorldManager.instance.repository.addBalance (Hex.decode(address), BigInteger.valueOf(2).pow(200) );
WorldManager.instance.getRepository().createAccount(Hex.decode(address));
WorldManager.instance.getRepository().addBalance (Hex.decode(address), BigInteger.valueOf(2).pow(200) );
}
this.setStateRoot( WorldManager.instance.repository.getRootHash() );
this.setStateRoot( WorldManager.instance.getRepository().getRootHash() );
logger.info("Genesis-hash: " + Hex.toHexString(this.getHash()));
logger.info("Genesis-stateRoot: " + Hex.toHexString(this.getStateRoot()));
WorldManager.instance.repository.dumpState(0, 0, null);
WorldManager.instance.getRepository().dumpState(0, 0, null);
}
public static Block getInstance() {

View File

@ -226,8 +226,8 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
}
byte[] contractAddress = Hex.decode( contractAddr );
final byte[] programCode = WorldManager.instance.repository.getCode(contractAddress);
final Map storageMap = WorldManager.instance.repository.getContractDetails(contractAddress).getStorage();
final byte[] programCode = WorldManager.instance.getRepository().getCode(contractAddress);
final Map storageMap = WorldManager.instance.getRepository().getContractDetails(contractAddress).getStorage();
contractDataInput.setBounds(70, 80, 350, 145);
contractDataInput.setViewportView(msgDataTA);
@ -301,13 +301,13 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
private void playContractCall() {
byte[] contractAddress = Hex.decode(contractAddrInput.getText());
ContractDetails contractDetails = WorldManager.instance.repository.getContractDetails(contractAddress);
ContractDetails contractDetails = WorldManager.instance.getRepository().getContractDetails(contractAddress);
if (contractDetails == null) {
alertStatusMsg("No contract for that address");
return;
}
byte[] programCode = WorldManager.instance.repository.getCode(contractAddress);
byte[] programCode = WorldManager.instance.getRepository().getCode(contractAddress);
if (programCode == null || programCode.length == 0) {
alertStatusMsg("Such account exist but no code in the db");
return;

View File

@ -42,6 +42,7 @@ public class WorldManager {
private Logger stateLogger = LoggerFactory.getLogger("state");
private Blockchain blockChain;
private Repository repository = new Repository();
private Wallet wallet = new Wallet();
private Map<String, Transaction> pendingTransactions = Collections
@ -49,8 +50,6 @@ public class WorldManager {
public DatabaseImpl chainDB = new DatabaseImpl("blockchain");
public Repository repository = new Repository();
public static WorldManager instance = new WorldManager();
public WorldManager() {
@ -320,6 +319,10 @@ public class WorldManager {
}
}
public Repository getRepository() {
return repository;
}
public Blockchain getBlockChain() {
return blockChain;
}