Public method to get repository
This commit is contained in:
parent
504a7e139f
commit
4037dc40c8
|
@ -71,7 +71,7 @@ public class Block {
|
||||||
timestamp, extraData, nonce);
|
timestamp, extraData, nonce);
|
||||||
this.txsState = new Trie(null);
|
this.txsState = new Trie(null);
|
||||||
|
|
||||||
byte[] stateRoot = WorldManager.instance.repository.getRootHash();
|
byte[] stateRoot = WorldManager.instance.getRepository().getRootHash();
|
||||||
this.header.setStateRoot(stateRoot);
|
this.header.setStateRoot(stateRoot);
|
||||||
|
|
||||||
this.header.setTxTrieRoot(txsState.getRootHash());
|
this.header.setTxTrieRoot(txsState.getRootHash());
|
||||||
|
|
|
@ -67,15 +67,15 @@ public class Genesis extends Block {
|
||||||
// The proof-of-concept series include a development premine, making the state root hash
|
// 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.
|
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
|
||||||
for (String address : premine) {
|
for (String address : premine) {
|
||||||
WorldManager.instance.repository.createAccount(Hex.decode(address));
|
WorldManager.instance.getRepository().createAccount(Hex.decode(address));
|
||||||
WorldManager.instance.repository.addBalance (Hex.decode(address), BigInteger.valueOf(2).pow(200) );
|
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-hash: " + Hex.toHexString(this.getHash()));
|
||||||
logger.info("Genesis-stateRoot: " + Hex.toHexString(this.getStateRoot()));
|
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() {
|
public static Block getInstance() {
|
||||||
|
|
|
@ -226,8 +226,8 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] contractAddress = Hex.decode( contractAddr );
|
byte[] contractAddress = Hex.decode( contractAddr );
|
||||||
final byte[] programCode = WorldManager.instance.repository.getCode(contractAddress);
|
final byte[] programCode = WorldManager.instance.getRepository().getCode(contractAddress);
|
||||||
final Map storageMap = WorldManager.instance.repository.getContractDetails(contractAddress).getStorage();
|
final Map storageMap = WorldManager.instance.getRepository().getContractDetails(contractAddress).getStorage();
|
||||||
|
|
||||||
contractDataInput.setBounds(70, 80, 350, 145);
|
contractDataInput.setBounds(70, 80, 350, 145);
|
||||||
contractDataInput.setViewportView(msgDataTA);
|
contractDataInput.setViewportView(msgDataTA);
|
||||||
|
@ -301,13 +301,13 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
|
||||||
private void playContractCall() {
|
private void playContractCall() {
|
||||||
|
|
||||||
byte[] contractAddress = Hex.decode(contractAddrInput.getText());
|
byte[] contractAddress = Hex.decode(contractAddrInput.getText());
|
||||||
ContractDetails contractDetails = WorldManager.instance.repository.getContractDetails(contractAddress);
|
ContractDetails contractDetails = WorldManager.instance.getRepository().getContractDetails(contractAddress);
|
||||||
if (contractDetails == null) {
|
if (contractDetails == null) {
|
||||||
alertStatusMsg("No contract for that address");
|
alertStatusMsg("No contract for that address");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] programCode = WorldManager.instance.repository.getCode(contractAddress);
|
byte[] programCode = WorldManager.instance.getRepository().getCode(contractAddress);
|
||||||
if (programCode == null || programCode.length == 0) {
|
if (programCode == null || programCode.length == 0) {
|
||||||
alertStatusMsg("Such account exist but no code in the db");
|
alertStatusMsg("Such account exist but no code in the db");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class WorldManager {
|
||||||
private Logger stateLogger = LoggerFactory.getLogger("state");
|
private Logger stateLogger = LoggerFactory.getLogger("state");
|
||||||
|
|
||||||
private Blockchain blockChain;
|
private Blockchain blockChain;
|
||||||
|
private Repository repository = new Repository();
|
||||||
private Wallet wallet = new Wallet();
|
private Wallet wallet = new Wallet();
|
||||||
|
|
||||||
private Map<String, Transaction> pendingTransactions = Collections
|
private Map<String, Transaction> pendingTransactions = Collections
|
||||||
|
@ -49,8 +50,6 @@ public class WorldManager {
|
||||||
|
|
||||||
public DatabaseImpl chainDB = new DatabaseImpl("blockchain");
|
public DatabaseImpl chainDB = new DatabaseImpl("blockchain");
|
||||||
|
|
||||||
public Repository repository = new Repository();
|
|
||||||
|
|
||||||
public static WorldManager instance = new WorldManager();
|
public static WorldManager instance = new WorldManager();
|
||||||
|
|
||||||
public WorldManager() {
|
public WorldManager() {
|
||||||
|
@ -320,6 +319,10 @@ public class WorldManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Repository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
public Blockchain getBlockChain() {
|
public Blockchain getBlockChain() {
|
||||||
return blockChain;
|
return blockChain;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue