mirror of
https://github.com/status-im/ethereumj-personal.git
synced 2025-02-22 08:28:08 +00:00
Fixed custom address initialization.
Fixed missing methods reference. Fixed ethereum initialization
This commit is contained in:
parent
67a0f7d35e
commit
5b83fbae43
@ -1,22 +1,13 @@
|
|||||||
package org.ethereum.android;
|
package org.ethereum.android;
|
||||||
|
|
||||||
|
|
||||||
import org.ethereum.android.manager.BlockLoader;
|
|
||||||
import org.ethereum.core.Block;
|
|
||||||
import org.ethereum.core.Genesis;
|
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.core.TransactionReceipt;
|
|
||||||
import org.ethereum.core.Wallet;
|
import org.ethereum.core.Wallet;
|
||||||
import org.ethereum.crypto.HashUtil;
|
|
||||||
import org.ethereum.db.BlockStore;
|
|
||||||
import org.ethereum.db.ByteArrayWrapper;
|
|
||||||
import org.ethereum.core.Blockchain;
|
|
||||||
import org.ethereum.core.Repository;
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.listener.CompositeEthereumListener;
|
|
||||||
import org.ethereum.listener.EthereumListener;
|
import org.ethereum.listener.EthereumListener;
|
||||||
import org.ethereum.manager.AdminInfo;
|
import org.ethereum.manager.AdminInfo;
|
||||||
|
import org.ethereum.manager.WorldManager;
|
||||||
import org.ethereum.net.client.PeerClient;
|
import org.ethereum.net.client.PeerClient;
|
||||||
import org.ethereum.net.peerdiscovery.PeerDiscovery;
|
|
||||||
import org.ethereum.net.peerdiscovery.PeerInfo;
|
import org.ethereum.net.peerdiscovery.PeerInfo;
|
||||||
import org.ethereum.net.rlpx.Node;
|
import org.ethereum.net.rlpx.Node;
|
||||||
import org.ethereum.net.server.ChannelManager;
|
import org.ethereum.net.server.ChannelManager;
|
||||||
@ -30,7 +21,6 @@ import org.spongycastle.util.encoders.Hex;
|
|||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -46,48 +36,34 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("facade");
|
private static final Logger logger = LoggerFactory.getLogger("facade");
|
||||||
|
|
||||||
BlockStore blockStore;
|
|
||||||
|
|
||||||
Blockchain blockchain;
|
|
||||||
|
|
||||||
Repository repository;
|
|
||||||
|
|
||||||
EthereumListener listener;
|
EthereumListener listener;
|
||||||
|
|
||||||
|
WorldManager worldManager;
|
||||||
|
|
||||||
AdminInfo adminInfo;
|
AdminInfo adminInfo;
|
||||||
|
|
||||||
ChannelManager channelManager;
|
ChannelManager channelManager;
|
||||||
|
|
||||||
PeerServer peerServer;
|
PeerServer peerServer;
|
||||||
|
|
||||||
PeerDiscovery peerDiscovery;
|
org.ethereum.manager.BlockLoader blockLoader;
|
||||||
|
|
||||||
BlockLoader blockLoader;
|
|
||||||
|
|
||||||
Provider<PeerClient> peerClientProvider;
|
Provider<PeerClient> peerClientProvider;
|
||||||
|
|
||||||
Wallet wallet;
|
|
||||||
|
|
||||||
private PeerClient activePeer;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Ethereum(Blockchain blockchain, BlockStore blockStore, Repository repository, AdminInfo adminInfo,
|
public Ethereum(WorldManager worldManager, AdminInfo adminInfo,
|
||||||
ChannelManager channelManager, BlockLoader blockLoader,
|
ChannelManager channelManager, org.ethereum.manager.BlockLoader blockLoader,
|
||||||
Provider<PeerClient> peerClientProvider, EthereumListener listener,
|
Provider<PeerClient> peerClientProvider, EthereumListener listener, PeerServer peerServer) {
|
||||||
PeerDiscovery peerDiscovery, Wallet wallet) {
|
|
||||||
|
|
||||||
System.out.println();
|
|
||||||
logger.info("EthereumImpl constructor");
|
logger.info("EthereumImpl constructor");
|
||||||
this.blockchain = blockchain;
|
this.worldManager = worldManager;
|
||||||
this.blockStore = blockStore;
|
|
||||||
this.repository = repository;
|
|
||||||
this.adminInfo = adminInfo;
|
this.adminInfo = adminInfo;
|
||||||
this.channelManager = channelManager;
|
this.channelManager = channelManager;
|
||||||
this.blockLoader = blockLoader;
|
this.blockLoader = blockLoader;
|
||||||
this.peerClientProvider = peerClientProvider;
|
this.peerClientProvider = peerClientProvider;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.peerDiscovery = peerDiscovery;
|
this.peerServer = peerServer;
|
||||||
this.wallet = wallet;
|
this.worldManager.setEthereum(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,14 +74,7 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
|
|
||||||
public void init(List<String> privateKeys) {
|
public void init(List<String> privateKeys) {
|
||||||
|
|
||||||
if (privateKeys != null) {
|
this.worldManager.init(privateKeys);
|
||||||
for (String privateKey: privateKeys) {
|
|
||||||
wallet.importKey(Hex.decode(privateKey));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the blockchain
|
|
||||||
loadBlockchain();
|
|
||||||
|
|
||||||
// Start peer server
|
// Start peer server
|
||||||
if (CONFIG.listenPort() > 0) {
|
if (CONFIG.listenPort() > 0) {
|
||||||
@ -119,72 +88,6 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] createRandomAccount() {
|
|
||||||
|
|
||||||
byte[] randomPrivateKey = HashUtil.sha3(HashUtil.randomPeerId());
|
|
||||||
wallet.importKey(randomPrivateKey);
|
|
||||||
return randomPrivateKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadBlockchain() {
|
|
||||||
|
|
||||||
if (!CONFIG.databaseReset())
|
|
||||||
blockStore.load();
|
|
||||||
|
|
||||||
Block bestBlock = blockStore.getBestBlock();
|
|
||||||
if (bestBlock == null) {
|
|
||||||
logger.info("DB is empty - adding Genesis");
|
|
||||||
|
|
||||||
Genesis genesis = (Genesis)Genesis.getInstance();
|
|
||||||
for (ByteArrayWrapper key : genesis.getPremine().keySet()) {
|
|
||||||
repository.createAccount(key.getData());
|
|
||||||
repository.addBalance(key.getData(), genesis.getPremine().get(key).getBalance());
|
|
||||||
}
|
|
||||||
|
|
||||||
blockStore.saveBlock(Genesis.getInstance(), Genesis.getInstance().getCumulativeDifficulty(), true);
|
|
||||||
|
|
||||||
blockchain.setBestBlock(Genesis.getInstance());
|
|
||||||
blockchain.setTotalDifficulty(Genesis.getInstance().getCumulativeDifficulty());
|
|
||||||
|
|
||||||
listener.onBlock(Genesis.getInstance(), new ArrayList<TransactionReceipt>() );
|
|
||||||
repository.dumpState(Genesis.getInstance(), 0, 0, null);
|
|
||||||
|
|
||||||
logger.info("Genesis block loaded");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
blockchain.setBestBlock(bestBlock);
|
|
||||||
|
|
||||||
BigInteger totalDifficulty = blockStore.getTotalDifficulty();
|
|
||||||
blockchain.setTotalDifficulty(totalDifficulty);
|
|
||||||
|
|
||||||
logger.info("*** Loaded up to block [{}] totalDifficulty [{}] with stateRoot [{}]",
|
|
||||||
blockchain.getBestBlock().getNumber(),
|
|
||||||
blockchain.getTotalDifficulty().toString(),
|
|
||||||
Hex.toHexString(blockchain.getBestBlock().getStateRoot()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CONFIG.rootHashStart() != null) {
|
|
||||||
|
|
||||||
// update world state by dummy hash
|
|
||||||
byte[] rootHash = Hex.decode(CONFIG.rootHashStart());
|
|
||||||
logger.info("Loading root hash from property file: [{}]", CONFIG.rootHashStart());
|
|
||||||
this.repository.syncToRoot(rootHash);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Update world state to latest loaded block from db
|
|
||||||
this.repository.syncToRoot(blockchain.getBestBlock().getStateRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* todo: return it when there is no state conflicts on the chain
|
|
||||||
boolean dbValid = this.repository.getWorldState().validate() || bestBlock.isGenesis();
|
|
||||||
if (!dbValid){
|
|
||||||
logger.error("The DB is not valid for that blockchain");
|
|
||||||
System.exit(-1); // todo: reset the repository and blockchain
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a peer but not this one
|
* Find a peer but not this one
|
||||||
*
|
*
|
||||||
@ -193,7 +96,6 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PeerInfo findOnlinePeer(PeerInfo peer) {
|
public PeerInfo findOnlinePeer(PeerInfo peer) {
|
||||||
|
|
||||||
Set<PeerInfo> excludePeers = new HashSet<>();
|
Set<PeerInfo> excludePeers = new HashSet<>();
|
||||||
excludePeers.add(peer);
|
excludePeers.add(peer);
|
||||||
return findOnlinePeer(excludePeers);
|
return findOnlinePeer(excludePeers);
|
||||||
@ -201,22 +103,20 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PeerInfo findOnlinePeer() {
|
public PeerInfo findOnlinePeer() {
|
||||||
|
|
||||||
Set<PeerInfo> excludePeers = new HashSet<>();
|
Set<PeerInfo> excludePeers = new HashSet<>();
|
||||||
return findOnlinePeer(excludePeers);
|
return findOnlinePeer(excludePeers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PeerInfo findOnlinePeer(Set<PeerInfo> excludePeers) {
|
public PeerInfo findOnlinePeer(Set<PeerInfo> excludePeers) {
|
||||||
|
|
||||||
logger.info("Looking for online peers...");
|
logger.info("Looking for online peers...");
|
||||||
|
|
||||||
final EthereumListener listener = this.listener;
|
final EthereumListener listener = this.listener;
|
||||||
listener.trace("Looking for online peer");
|
listener.trace("Looking for online peer");
|
||||||
|
|
||||||
startPeerDiscovery();
|
worldManager.startPeerDiscovery();
|
||||||
|
|
||||||
final Set<PeerInfo> peers = getPeers();
|
final Set<PeerInfo> peers = worldManager.getPeerDiscovery().getPeers();
|
||||||
for (PeerInfo peer : peers) { // it blocks until a peer is available.
|
for (PeerInfo peer : peers) { // it blocks until a peer is available.
|
||||||
if (peer.isOnline() && !excludePeers.contains(peer)) {
|
if (peer.isOnline() && !excludePeers.contains(peer)) {
|
||||||
logger.info("Found peer: {}", peer.toString());
|
logger.info("Found peer: {}", peer.toString());
|
||||||
@ -244,80 +144,71 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<PeerInfo> getPeers() {
|
public Set<PeerInfo> getPeers() {
|
||||||
|
return worldManager.getPeerDiscovery().getPeers();
|
||||||
return peerDiscovery.getPeers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startPeerDiscovery() {
|
public void startPeerDiscovery() {
|
||||||
|
worldManager.startPeerDiscovery();
|
||||||
if (!peerDiscovery.isStarted())
|
|
||||||
peerDiscovery.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopPeerDiscovery() {
|
public void stopPeerDiscovery() {
|
||||||
|
worldManager.stopPeerDiscovery();
|
||||||
if (peerDiscovery.isStarted())
|
|
||||||
peerDiscovery.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(InetAddress addr, int port, String remoteId) {
|
public void connect(InetAddress addr, int port, String remoteId) {
|
||||||
|
|
||||||
connect(addr.getHostName(), port, remoteId);
|
connect(addr.getHostName(), port, remoteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(String ip, int port, String remoteId) {
|
public void connect(final String ip, final int port, final String remoteId) {
|
||||||
|
|
||||||
logger.info("Connecting to: {}:{}", ip, port);
|
logger.info("Connecting to: {}:{}", ip, port);
|
||||||
|
final PeerClient peerClient = peerClientProvider.get();
|
||||||
if (activePeer == null)
|
Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||||
activePeer = peerClientProvider.get();
|
@Override
|
||||||
|
public void run() {
|
||||||
activePeer.connect(ip, port, remoteId);
|
peerClient.connect(ip, port, remoteId);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(Node node) {
|
public void connect(Node node) {
|
||||||
|
|
||||||
connect(node.getHost(), node.getPort(), Hex.toHexString(node.getId()));
|
connect(node.getHost(), node.getPort(), Hex.toHexString(node.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.ethereum.facade.Blockchain getBlockchain() {
|
public org.ethereum.facade.Blockchain getBlockchain() {
|
||||||
|
return (org.ethereum.facade.Blockchain)worldManager.getBlockchain();
|
||||||
return (org.ethereum.facade.Blockchain)blockchain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(EthereumListener listener) {
|
public void addListener(EthereumListener listener) {
|
||||||
|
worldManager.addListener(listener);
|
||||||
((CompositeEthereumListener) this.listener).addListener(listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
worldManager.close();
|
||||||
stopPeerDiscovery();
|
|
||||||
repository.close();
|
|
||||||
blockchain.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PeerClient getDefaultPeer() {
|
public PeerClient getDefaultPeer() {
|
||||||
|
|
||||||
if (activePeer == null) {
|
PeerClient peer = worldManager.getActivePeer();
|
||||||
activePeer = peerClientProvider.get();
|
if (peer == null) {
|
||||||
|
|
||||||
|
peer = peerClientProvider.get();
|
||||||
|
worldManager.setActivePeer(peer);
|
||||||
}
|
}
|
||||||
return activePeer;
|
return peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
|
return worldManager.getActivePeer() != null;
|
||||||
return activePeer != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -348,50 +239,49 @@ public class Ethereum implements org.ethereum.facade.Ethereum {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Wallet getWallet() {
|
public Wallet getWallet() {
|
||||||
|
return worldManager.getWallet();
|
||||||
return wallet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.ethereum.facade.Repository getRepository() {
|
public org.ethereum.facade.Repository getRepository() {
|
||||||
|
return worldManager.getRepository();
|
||||||
|
}
|
||||||
|
|
||||||
return (org.ethereum.facade.Repository)repository;
|
@Override
|
||||||
|
public org.ethereum.facade.Repository getSnapshootTo(byte[] root){
|
||||||
|
|
||||||
|
Repository repository = (Repository) worldManager.getRepository();
|
||||||
|
org.ethereum.facade.Repository snapshot = (org.ethereum.facade.Repository) repository.getSnapshotTo(root);
|
||||||
|
|
||||||
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AdminInfo getAdminInfo() {
|
public AdminInfo getAdminInfo() {
|
||||||
|
|
||||||
return adminInfo;
|
return adminInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelManager getChannelManager() {
|
public ChannelManager getChannelManager() {
|
||||||
|
|
||||||
return channelManager;
|
return channelManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Transaction> getPendingTransactions() {
|
public Set<Transaction> getPendingTransactions() {
|
||||||
|
return getBlockchain().getPendingTransactions();
|
||||||
return blockchain.getPendingTransactions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockLoader getBlockLoader() {
|
public org.ethereum.manager.BlockLoader getBlockLoader(){
|
||||||
|
|
||||||
return blockLoader;
|
return blockLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exitOn(long number) {
|
public void exitOn(long number) {
|
||||||
|
worldManager.getBlockchain().setExitOn(number);
|
||||||
blockchain.setExitOn(number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.ethereum.facade.Repository getSnapshootTo(byte[] root) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,21 @@ import org.ethereum.android.db.OrmLiteBlockStoreDatabase;
|
|||||||
import org.ethereum.config.SystemProperties;
|
import org.ethereum.config.SystemProperties;
|
||||||
import org.ethereum.core.Blockchain;
|
import org.ethereum.core.Blockchain;
|
||||||
import org.ethereum.android.manager.BlockLoader;
|
import org.ethereum.android.manager.BlockLoader;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.datasource.HashMapDB;
|
import org.ethereum.datasource.HashMapDB;
|
||||||
import org.ethereum.datasource.KeyValueDataSource;
|
import org.ethereum.datasource.KeyValueDataSource;
|
||||||
import org.ethereum.android.datasource.LevelDbDataSource;
|
import org.ethereum.android.datasource.LevelDbDataSource;
|
||||||
import org.ethereum.db.BlockStore;
|
import org.ethereum.db.BlockStore;
|
||||||
import org.ethereum.db.IndexedBlockStore;
|
import org.ethereum.db.IndexedBlockStore;
|
||||||
|
import org.ethereum.db.RepositoryImpl;
|
||||||
|
import org.ethereum.facade.Ethereum;
|
||||||
|
import org.ethereum.facade.EthereumImpl;
|
||||||
|
import org.ethereum.listener.EthereumListener;
|
||||||
|
import org.ethereum.manager.AdminInfo;
|
||||||
|
import org.ethereum.manager.WorldManager;
|
||||||
|
import org.ethereum.net.client.PeerClient;
|
||||||
|
import org.ethereum.net.server.ChannelManager;
|
||||||
|
import org.ethereum.net.server.PeerServer;
|
||||||
import org.mapdb.DB;
|
import org.mapdb.DB;
|
||||||
import org.mapdb.DBMaker;
|
import org.mapdb.DBMaker;
|
||||||
import org.mapdb.Serializer;
|
import org.mapdb.Serializer;
|
||||||
@ -48,6 +58,19 @@ public class EthereumModule extends org.ethereum.di.modules.EthereumModule {
|
|||||||
this.storeAllBlocks = storeAllBlocks;
|
this.storeAllBlocks = storeAllBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Ethereum createEthereum(WorldManager worldManager, AdminInfo adminInfo, ChannelManager channelManager,
|
||||||
|
org.ethereum.manager.BlockLoader blockLoader, Provider<PeerClient> peerClientProvider, EthereumListener listener, PeerServer peerServer) {
|
||||||
|
return new org.ethereum.android.Ethereum(worldManager, adminInfo, channelManager, blockLoader, peerClientProvider, listener, peerServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Repository createRepository() {
|
||||||
|
LevelDbDataSource detailsDS = new LevelDbDataSource();
|
||||||
|
LevelDbDataSource stateDS = new LevelDbDataSource();
|
||||||
|
return new RepositoryImpl(detailsDS, stateDS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlockStore createBlockStore() {
|
protected BlockStore createBlockStore() {
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import org.ethereum.core.Account;
|
|||||||
import org.ethereum.core.AccountState;
|
import org.ethereum.core.AccountState;
|
||||||
import org.ethereum.core.Block;
|
import org.ethereum.core.Block;
|
||||||
import org.ethereum.core.BlockHeader;
|
import org.ethereum.core.BlockHeader;
|
||||||
|
import org.ethereum.core.Blockchain;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.core.TransactionReceipt;
|
import org.ethereum.core.TransactionReceipt;
|
||||||
import org.ethereum.crypto.HashUtil;
|
import org.ethereum.crypto.HashUtil;
|
||||||
@ -302,8 +303,8 @@ public abstract class JsonRpcServerMethod implements RequestHandler {
|
|||||||
for (Transaction tx : block.getTransactionsList()) {
|
for (Transaction tx : block.getTransactionsList()) {
|
||||||
if (Arrays.equals(tx.getHash(), transaction.getTransaction().getHash()))
|
if (Arrays.equals(tx.getHash(), transaction.getTransaction().getHash()))
|
||||||
break;
|
break;
|
||||||
// TODO: Missing method on blockchain
|
Blockchain blockchain = (Blockchain)ethereum.getBlockchain();
|
||||||
//txli += this.ethereum.getBlockchain().getTransactionReceiptByHash(transaction.getTransaction().getHash()).getLogInfoList().size();
|
txli += blockchain.getTransactionReceiptByHash(transaction.getTransaction().getHash()).getLogInfoList().size();
|
||||||
txi++;
|
txi++;
|
||||||
}
|
}
|
||||||
res.put("transactionIndex", "0x" + Long.toHexString(txi));
|
res.put("transactionIndex", "0x" + Long.toHexString(txi));
|
||||||
|
@ -4,6 +4,7 @@ import net.minidev.json.JSONArray;
|
|||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
|
|
||||||
import org.ethereum.core.Block;
|
import org.ethereum.core.Block;
|
||||||
|
import org.ethereum.core.Blockchain;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.core.TransactionReceipt;
|
import org.ethereum.core.TransactionReceipt;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
@ -111,16 +112,14 @@ TODO: Roman must implement Bloom contain. When it will be done - we can use just
|
|||||||
if (block == null)
|
if (block == null)
|
||||||
break;
|
break;
|
||||||
for (Transaction tx : block.getTransactionsList()) {
|
for (Transaction tx : block.getTransactionsList()) {
|
||||||
// TODO: Missing method on blockchain
|
Blockchain blockchain = (Blockchain)ethereum.getBlockchain();
|
||||||
/*
|
TransactionReceipt txr = blockchain.getTransactionReceiptByHash(tx.getHash());
|
||||||
TransactionReceipt txr = ethereum.getBlockchain().getTransactionReceiptByHash(tx.getHash());
|
|
||||||
if (txr != null) {
|
if (txr != null) {
|
||||||
for (LogInfo li : txr.getLogInfoList()) {
|
for (LogInfo li : txr.getLogInfoList()) {
|
||||||
if (checkLogInfo(li))
|
if (checkLogInfo(li))
|
||||||
res.add(logInfoToJS(new FilterLogData(block, txr, li)));
|
res.add(logInfoToJS(new FilterLogData(block, txr, li)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -128,16 +127,14 @@ TODO: Roman must implement Bloom contain. When it will be done - we can use just
|
|||||||
|
|
||||||
if (blockFrom < 0 || blockTo < 0) {
|
if (blockFrom < 0 || blockTo < 0) {
|
||||||
for (Transaction tx : ethereum.getPendingTransactions()) {
|
for (Transaction tx : ethereum.getPendingTransactions()) {
|
||||||
// TODO: Missing method on blockchain
|
Blockchain blockchain = (Blockchain)ethereum.getBlockchain();
|
||||||
/*
|
TransactionReceipt txr = blockchain.getTransactionReceiptByHash(tx.getHash());
|
||||||
TransactionReceipt txr = ethereum.getBlockchain().getTransactionReceiptByHash(tx.getHash());
|
|
||||||
if (txr != null) {
|
if (txr != null) {
|
||||||
for (LogInfo li : txr.getLogInfoList()) {
|
for (LogInfo li : txr.getLogInfoList()) {
|
||||||
if (checkLogInfo(li))
|
if (checkLogInfo(li))
|
||||||
res.add(logInfoToJS(new FilterLogData(null, txr, li)));
|
res.add(logInfoToJS(new FilterLogData(null, txr, li)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,14 +188,12 @@ TODO: Roman must implement Bloom contain. When it will be done - we can use just
|
|||||||
TODO: for me it's a little strange way.
|
TODO: for me it's a little strange way.
|
||||||
*/
|
*/
|
||||||
for (Transaction tx : data.block.getTransactionsList()) {
|
for (Transaction tx : data.block.getTransactionsList()) {
|
||||||
// TODO: Missing method on blockchain
|
Blockchain blockchain = (Blockchain)ethereum.getBlockchain();
|
||||||
/*
|
for (LogInfo li : blockchain.getTransactionReceiptByHash(tx.getHash()).getLogInfoList()) {
|
||||||
for (LogInfo li : ethereum.getBlockchain().getTransactionReceiptByHash(tx.getHash()).getLogInfoList()) {
|
|
||||||
if (li.getBloom().equals(data.li.getBloom()))
|
if (li.getBloom().equals(data.li.getBloom()))
|
||||||
break;
|
break;
|
||||||
lii++;
|
lii++;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if (Arrays.equals(tx.getHash(), data.txr.getTransaction().getHash())) {
|
if (Arrays.equals(tx.getHash(), data.txr.getTransaction().getHash())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.thetransactioncompany.jsonrpc2.*;
|
|||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import org.ethereum.vm.Program;
|
import org.ethereum.vm.Program;
|
||||||
@ -36,8 +37,8 @@ public class eth_call extends JsonRpcServerMethod {
|
|||||||
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
repository.syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
VM vm = new VM();
|
VM vm = new VM();
|
||||||
@ -46,8 +47,8 @@ public class eth_call extends JsonRpcServerMethod {
|
|||||||
byte[] result = program.getResult().getHReturn();
|
byte[] result = program.getResult().getHReturn();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(root);
|
repository.syncToRoot(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "0x" + Hex.toHexString(result);
|
String tmp = "0x" + Hex.toHexString(result);
|
||||||
|
@ -4,6 +4,7 @@ import com.thetransactioncompany.jsonrpc2.*;
|
|||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import org.ethereum.vm.Program;
|
import org.ethereum.vm.Program;
|
||||||
@ -36,8 +37,8 @@ public class eth_estimateGas extends JsonRpcServerMethod {
|
|||||||
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
repository.syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
VM vm = new VM();
|
VM vm = new VM();
|
||||||
@ -46,8 +47,8 @@ public class eth_estimateGas extends JsonRpcServerMethod {
|
|||||||
long result = program.getResult().getGasUsed();
|
long result = program.getResult().getGasUsed();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(root);
|
repository.syncToRoot(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "0x" + Long.toHexString(result);
|
String tmp = "0x" + Long.toHexString(result);
|
||||||
|
@ -4,6 +4,7 @@ import com.thetransactioncompany.jsonrpc2.*;
|
|||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
import org.ethereum.core.AccountState;
|
import org.ethereum.core.AccountState;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -29,8 +30,8 @@ public class eth_getBalance extends JsonRpcServerMethod {
|
|||||||
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
repository.syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
BigInteger balance = ethereum.getRepository().getBalance(address);
|
BigInteger balance = ethereum.getRepository().getBalance(address);
|
||||||
@ -41,8 +42,8 @@ public class eth_getBalance extends JsonRpcServerMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(root);
|
repository.syncToRoot(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "0x" + balance.toString(16);
|
String tmp = "0x" + balance.toString(16);
|
||||||
|
@ -3,6 +3,7 @@ package org.ethereum.android.jsonrpc.full.method;
|
|||||||
import com.thetransactioncompany.jsonrpc2.*;
|
import com.thetransactioncompany.jsonrpc2.*;
|
||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -27,15 +28,15 @@ public class eth_getCode extends JsonRpcServerMethod {
|
|||||||
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
repository.syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "0x" + Hex.toHexString(ethereum.getRepository().getCode(address));
|
String tmp = "0x" + Hex.toHexString(ethereum.getRepository().getCode(address));
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(root);
|
repository.syncToRoot(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID());
|
||||||
|
@ -4,6 +4,7 @@ import com.thetransactioncompany.jsonrpc2.*;
|
|||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServer;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServer;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import org.ethereum.vm.DataWord;
|
import org.ethereum.vm.DataWord;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
@ -28,15 +29,15 @@ public class eth_getStorageAt extends JsonRpcServerMethod {
|
|||||||
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
repository.syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "0x" + Hex.toHexString(ethereum.getRepository().getStorageValue(address, new DataWord(key)).getData());
|
String tmp = "0x" + Hex.toHexString(ethereum.getRepository().getStorageValue(address, new DataWord(key)).getData());
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
//ethereum.getRepository().syncToRoot(root);
|
repository.syncToRoot(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID());
|
||||||
|
@ -4,6 +4,7 @@ import com.thetransactioncompany.jsonrpc2.*;
|
|||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
import org.ethereum.core.TransactionReceipt;
|
import org.ethereum.core.TransactionReceipt;
|
||||||
|
import org.ethereum.core.Blockchain;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,9 +22,8 @@ public class eth_getTransactionByHash extends JsonRpcServerMethod {
|
|||||||
} else {
|
} else {
|
||||||
byte[] address = jsToAddress((String) params.get(0));
|
byte[] address = jsToAddress((String) params.get(0));
|
||||||
|
|
||||||
// TODO: Missing method on repository
|
Blockchain blockchain = (Blockchain)ethereum.getBlockchain();
|
||||||
/*
|
TransactionReceipt transaction = blockchain.getTransactionReceiptByHash(address);
|
||||||
TransactionReceipt transaction = ethereum.getBlockchain().getTransactionReceiptByHash(address);
|
|
||||||
|
|
||||||
|
|
||||||
if (transaction == null)
|
if (transaction == null)
|
||||||
@ -31,8 +31,6 @@ public class eth_getTransactionByHash extends JsonRpcServerMethod {
|
|||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(transactionToJS(null, transaction.getTransaction()), req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(transactionToJS(null, transaction.getTransaction()), req.getID());
|
||||||
return res;
|
return res;
|
||||||
*/
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.thetransactioncompany.jsonrpc2.server.*;
|
|||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServer;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServer;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
import org.ethereum.core.AccountState;
|
import org.ethereum.core.AccountState;
|
||||||
|
import org.ethereum.core.Repository;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
@ -18,6 +19,7 @@ public class eth_getTransactionCount extends JsonRpcServerMethod {
|
|||||||
|
|
||||||
protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) {
|
protected JSONRPC2Response worker(JSONRPC2Request req, MessageContext ctx) {
|
||||||
|
|
||||||
|
Repository repository = (Repository)ethereum.getRepository();
|
||||||
List<Object> params = req.getPositionalParams();
|
List<Object> params = req.getPositionalParams();
|
||||||
if (params.size() != 2) {
|
if (params.size() != 2) {
|
||||||
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID());
|
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID());
|
||||||
@ -30,16 +32,14 @@ public class eth_getTransactionCount extends JsonRpcServerMethod {
|
|||||||
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
byte[] root = ethereum.getBlockchain().getBestBlock().getStateRoot();
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
repository.syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
||||||
//ethereum.getRepository().syncToRoot(ethereum.getBlockchain().getBlockByNumber(blockNumber).getStateRoot());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BigInteger nonce = BigInteger.ZERO;
|
BigInteger nonce = BigInteger.ZERO;
|
||||||
|
|
||||||
// TODO: Missing method on repository
|
AccountState accountState = repository.getAccountState(address);
|
||||||
//AccountState accountState = ethereum.getRepository().getAccountState(address);
|
if (accountState != null)
|
||||||
//if (accountState != null)
|
nonce = accountState.getNonce();
|
||||||
// nonce = accountState.getNonce();
|
|
||||||
|
|
||||||
if (blockNumber == -1) {
|
if (blockNumber == -1) {
|
||||||
synchronized (ethereum.getBlockchain().getPendingTransactions()) {
|
synchronized (ethereum.getBlockchain().getPendingTransactions()) {
|
||||||
@ -52,8 +52,7 @@ public class eth_getTransactionCount extends JsonRpcServerMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (blockNumber >= 0) {
|
if (blockNumber >= 0) {
|
||||||
// TODO: Missing method on repository
|
repository.syncToRoot(root);
|
||||||
//ethereum.getRepository().syncToRoot(root);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp = "0x" + nonce.toString(16);
|
String tmp = "0x" + nonce.toString(16);
|
||||||
|
@ -3,6 +3,7 @@ package org.ethereum.android.jsonrpc.full.method;
|
|||||||
import com.thetransactioncompany.jsonrpc2.*;
|
import com.thetransactioncompany.jsonrpc2.*;
|
||||||
import com.thetransactioncompany.jsonrpc2.server.*;
|
import com.thetransactioncompany.jsonrpc2.server.*;
|
||||||
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.full.JsonRpcServerMethod;
|
||||||
|
import org.ethereum.core.Blockchain;
|
||||||
import org.ethereum.core.TransactionReceipt;
|
import org.ethereum.core.TransactionReceipt;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,17 +22,14 @@ public class eth_getTransactionReceipt extends JsonRpcServerMethod {
|
|||||||
} else {
|
} else {
|
||||||
byte[] address = jsToAddress((String) params.get(0));
|
byte[] address = jsToAddress((String) params.get(0));
|
||||||
|
|
||||||
// TODO: Missing method on blockchain
|
Blockchain blockchain = (Blockchain)ethereum.getBlockchain();
|
||||||
/*
|
TransactionReceipt transaction = blockchain.getTransactionReceiptByHash(address);
|
||||||
TransactionReceipt transaction = ethereum.getBlockchain().getTransactionReceiptByHash(address);
|
|
||||||
|
|
||||||
if (transaction == null)
|
if (transaction == null)
|
||||||
return new JSONRPC2Response(null, req.getID());
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(transactionReceiptToJS(null, transaction), req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(transactionReceiptToJS(null, transaction), req.getID());
|
||||||
return res;
|
return res;
|
||||||
*/
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import org.ethereum.android.service.events.PeerDisconnectEventData;
|
|||||||
import org.ethereum.android.service.events.PendingTransactionsEventData;
|
import org.ethereum.android.service.events.PendingTransactionsEventData;
|
||||||
import org.ethereum.android.service.events.TraceEventData;
|
import org.ethereum.android.service.events.TraceEventData;
|
||||||
import org.ethereum.android.service.events.VMTraceCreatedEventData;
|
import org.ethereum.android.service.events.VMTraceCreatedEventData;
|
||||||
|
import org.ethereum.config.SystemProperties;
|
||||||
import org.ethereum.core.Genesis;
|
import org.ethereum.core.Genesis;
|
||||||
import org.ethereum.core.Transaction;
|
import org.ethereum.core.Transaction;
|
||||||
import org.ethereum.core.TransactionReceipt;
|
import org.ethereum.core.TransactionReceipt;
|
||||||
@ -69,26 +70,28 @@ public class EthereumService extends Service {
|
|||||||
ethereum.close();
|
ethereum.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class InitializeTask extends AsyncTask<Ethereum, Message, Void> {
|
protected class InitializeTask extends AsyncTask<Ethereum, Message, Ethereum> {
|
||||||
|
|
||||||
public InitializeTask() {
|
public InitializeTask() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Void doInBackground(Ethereum... args) {
|
protected Ethereum doInBackground(Ethereum... args) {
|
||||||
|
|
||||||
initializeEthereum();
|
return initializeEthereum();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Void results) {
|
protected void onPostExecute(Ethereum results) {
|
||||||
|
|
||||||
|
|
||||||
|
if (results != null) {
|
||||||
|
EthereumService.ethereum = results;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initializeEthereum() {
|
protected Ethereum initializeEthereum() {
|
||||||
|
|
||||||
|
Ethereum ethereum = null;
|
||||||
if (!isInitialized) {
|
if (!isInitialized) {
|
||||||
System.setProperty("sun.arch.data.model", "32");
|
System.setProperty("sun.arch.data.model", "32");
|
||||||
System.setProperty("leveldb.mmap", "false");
|
System.setProperty("leveldb.mmap", "false");
|
||||||
@ -116,6 +119,8 @@ public class EthereumService extends Service {
|
|||||||
System.out.println(" Already initialized");
|
System.out.println(" Already initialized");
|
||||||
System.out.println("x " + (ethereum != null));
|
System.out.println("x " + (ethereum != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ethereum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -195,11 +200,13 @@ public class EthereumService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onEthStatusUpdated(Node node, StatusMessage status) {
|
public void onEthStatusUpdated(Node node, StatusMessage status) {
|
||||||
// TODO: add boardcast event
|
// TODO: add boardcast event
|
||||||
|
System.out.println(node.getHost() + " = " + status.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNodeDiscovered(Node node) {
|
public void onNodeDiscovered(Node node) {
|
||||||
// TODO: add broadcast event
|
// TODO: add broadcast event
|
||||||
|
System.out.println(node.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,11 @@ public class SystemProperties {
|
|||||||
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
InputStream is = ClassLoader.getSystemResourceAsStream("version.properties");
|
InputStream is = ClassLoader.getSystemResourceAsStream("version.properties");
|
||||||
props.load(is);
|
if (is != null) {
|
||||||
this.projectVersion = props.getProperty("versionNumber");
|
props.load(is);
|
||||||
this.projectVersion = this.projectVersion.replaceAll("'", "");
|
this.projectVersion = props.getProperty("versionNumber");
|
||||||
|
this.projectVersion = this.projectVersion.replaceAll("'", "");
|
||||||
|
}
|
||||||
|
|
||||||
if (this.projectVersion == null) this.projectVersion = "-.-.-";
|
if (this.projectVersion == null) this.projectVersion = "-.-.-";
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import org.ethereum.net.rlpx.discover.NodeManager;
|
|||||||
import org.ethereum.net.rlpx.discover.PeerConnectionTester;
|
import org.ethereum.net.rlpx.discover.PeerConnectionTester;
|
||||||
import org.ethereum.net.server.ChannelManager;
|
import org.ethereum.net.server.ChannelManager;
|
||||||
import org.ethereum.net.server.EthereumChannelInitializer;
|
import org.ethereum.net.server.EthereumChannelInitializer;
|
||||||
|
import org.ethereum.net.server.PeerServer;
|
||||||
import org.ethereum.net.shh.ShhHandler;
|
import org.ethereum.net.shh.ShhHandler;
|
||||||
import org.ethereum.net.rlpx.MessageCodec;
|
import org.ethereum.net.rlpx.MessageCodec;
|
||||||
import org.ethereum.vm.ProgramInvokeFactory;
|
import org.ethereum.vm.ProgramInvokeFactory;
|
||||||
@ -64,8 +65,13 @@ public class EthereumModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public Ethereum provideEthereum(WorldManager worldManager, AdminInfo adminInfo, ChannelManager channelManager,
|
public Ethereum provideEthereum(WorldManager worldManager, AdminInfo adminInfo, ChannelManager channelManager,
|
||||||
BlockLoader blockLoader, Provider<PeerClient> peerClientProvider, EthereumListener listener) {
|
BlockLoader blockLoader, Provider<PeerClient> peerClientProvider, EthereumListener listener, PeerServer peerServer) {
|
||||||
return new EthereumImpl(worldManager, adminInfo, channelManager, blockLoader, peerClientProvider, listener);
|
return createEthereum(worldManager, adminInfo, channelManager, blockLoader, peerClientProvider, listener, peerServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Ethereum createEthereum(WorldManager worldManager, AdminInfo adminInfo, ChannelManager channelManager,
|
||||||
|
BlockLoader blockLoader, Provider<PeerClient> peerClientProvider, EthereumListener listener, PeerServer peerServer) {
|
||||||
|
return new EthereumImpl(worldManager, adminInfo, channelManager, blockLoader, peerClientProvider, listener, peerServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -75,6 +81,12 @@ public class EthereumModule {
|
|||||||
return new WorldManager(blockchain, repository, wallet, peerDiscovery, blockStore, channelManager, adminInfo, listener, nodeManager, syncManager);
|
return new WorldManager(blockchain, repository, wallet, peerDiscovery, blockStore, channelManager, adminInfo, listener, nodeManager, syncManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
public PeerServer providePeerServer(ChannelManager channelManager, EthereumChannelInitializer ethereumChannelInitializer, EthereumListener listener) {
|
||||||
|
return new PeerServer(channelManager, ethereumChannelInitializer, listener);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public Blockchain provideBlockchain(BlockStore blockStore, Repository repository,
|
public Blockchain provideBlockchain(BlockStore blockStore, Repository repository,
|
||||||
@ -123,6 +135,10 @@ public class EthereumModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public Repository provideRepository() {
|
public Repository provideRepository() {
|
||||||
|
return createRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Repository createRepository() {
|
||||||
MapDBDataSource detailsDS = new MapDBDataSource();
|
MapDBDataSource detailsDS = new MapDBDataSource();
|
||||||
MapDBDataSource stateDS = new MapDBDataSource();
|
MapDBDataSource stateDS = new MapDBDataSource();
|
||||||
return new RepositoryImpl(detailsDS, stateDS);
|
return new RepositoryImpl(detailsDS, stateDS);
|
||||||
|
@ -57,8 +57,7 @@ public class EthereumImpl implements Ethereum {
|
|||||||
@Inject
|
@Inject
|
||||||
public EthereumImpl(WorldManager worldManager, AdminInfo adminInfo,
|
public EthereumImpl(WorldManager worldManager, AdminInfo adminInfo,
|
||||||
ChannelManager channelManager, BlockLoader blockLoader,
|
ChannelManager channelManager, BlockLoader blockLoader,
|
||||||
Provider<PeerClient> peerClientProvider, EthereumListener listener) {
|
Provider<PeerClient> peerClientProvider, EthereumListener listener, PeerServer peerServer) {
|
||||||
System.out.println();
|
|
||||||
logger.info("EthereumImpl constructor");
|
logger.info("EthereumImpl constructor");
|
||||||
this.worldManager = worldManager;
|
this.worldManager = worldManager;
|
||||||
this.adminInfo = adminInfo;
|
this.adminInfo = adminInfo;
|
||||||
@ -66,8 +65,9 @@ public class EthereumImpl implements Ethereum {
|
|||||||
this.blockLoader = blockLoader;
|
this.blockLoader = blockLoader;
|
||||||
this.peerClientProvider = peerClientProvider;
|
this.peerClientProvider = peerClientProvider;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
this.peerServer = peerServer;
|
||||||
this.worldManager.setEthereum(this);
|
this.worldManager.setEthereum(this);
|
||||||
|
this.worldManager.init(null);
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ import org.spongycastle.util.encoders.Hex;
|
|||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -77,16 +79,14 @@ public class WorldManager {
|
|||||||
this.syncManager.setBlockChain(this.blockchain);
|
this.syncManager.setBlockChain(this.blockchain);
|
||||||
this.channelManager.setSyncManager(this.syncManager);
|
this.channelManager.setSyncManager(this.syncManager);
|
||||||
|
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init(List<String> privateKeys) {
|
||||||
byte[] cowAddr = HashUtil.sha3("cow".getBytes());
|
if (privateKeys != null) {
|
||||||
wallet.importKey(cowAddr);
|
for (String privateKey: privateKeys) {
|
||||||
|
wallet.importKey(Hex.decode(privateKey));
|
||||||
String secret = CONFIG.coinbaseSecret();
|
}
|
||||||
byte[] cbAddr = HashUtil.sha3(secret.getBytes());
|
}
|
||||||
wallet.importKey(cbAddr);
|
|
||||||
|
|
||||||
loadBlockchain();
|
loadBlockchain();
|
||||||
syncManager.init();
|
syncManager.init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user