additional changes after latest Skype call with Roman.
This commit is contained in:
parent
33be741881
commit
7e61c3765c
|
@ -37,6 +37,8 @@ import static io.netty.handler.codec.http.HttpHeaders.Names.*;
|
||||||
|
|
||||||
import org.ethereum.android.jsonrpc.method.*;
|
import org.ethereum.android.jsonrpc.method.*;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
|
||||||
public final class JsonRpcServer {
|
public final class JsonRpcServer {
|
||||||
|
|
||||||
|
@ -123,8 +125,8 @@ public final class JsonRpcServer {
|
||||||
try {
|
try {
|
||||||
ServerBootstrap b = new ServerBootstrap();
|
ServerBootstrap b = new ServerBootstrap();
|
||||||
b.option(ChannelOption.SO_BACKLOG, 1024);
|
b.option(ChannelOption.SO_BACKLOG, 1024);
|
||||||
// b.localAddress(InetAddress.getLocalHost(), PORT);
|
b.localAddress(InetAddress.getLocalHost(), PORT);
|
||||||
b.localAddress(PORT);
|
// b.localAddress(PORT);
|
||||||
b.group(bossGroup, workerGroup)
|
b.group(bossGroup, workerGroup)
|
||||||
.channel(NioServerSocketChannel.class)
|
.channel(NioServerSocketChannel.class)
|
||||||
.childHandler(new JsonRpcServerInitializer());
|
.childHandler(new JsonRpcServerInitializer());
|
||||||
|
|
|
@ -204,7 +204,7 @@ public abstract class JsonRpcServerMethod implements RequestHandler {
|
||||||
i = 0;
|
i = 0;
|
||||||
for (Transaction transaction : block.getTransactionsList()) {
|
for (Transaction transaction : block.getTransactionsList()) {
|
||||||
if (detailed) {
|
if (detailed) {
|
||||||
JSONObject tx = transactionToJS(transaction);
|
JSONObject tx = transactionToJS(block, transaction);
|
||||||
tx.put("transactionIndex", "0x" + Integer.toHexString(i));
|
tx.put("transactionIndex", "0x" + Integer.toHexString(i));
|
||||||
tx.put("blockHash", "0x" + Hex.toHexString(block.getHash()));
|
tx.put("blockHash", "0x" + Hex.toHexString(block.getHash()));
|
||||||
tx.put("blockNumber", "0x" + Long.toHexString(block.getNumber()));
|
tx.put("blockNumber", "0x" + Long.toHexString(block.getNumber()));
|
||||||
|
@ -216,7 +216,6 @@ public abstract class JsonRpcServerMethod implements RequestHandler {
|
||||||
}
|
}
|
||||||
res.put("transactions", transactionsJA);
|
res.put("transactions", transactionsJA);
|
||||||
|
|
||||||
//TODO: ask if I correctly get uncle's hash (takes form -core right now)
|
|
||||||
JSONArray unclesJA = new JSONArray();
|
JSONArray unclesJA = new JSONArray();
|
||||||
for (BlockHeader uncle : block.getUncleList()) {
|
for (BlockHeader uncle : block.getUncleList()) {
|
||||||
unclesJA.add("0x" + Hex.toHexString(HashUtil.sha3(uncle.getEncoded())));
|
unclesJA.add("0x" + Hex.toHexString(HashUtil.sha3(uncle.getEncoded())));
|
||||||
|
@ -226,7 +225,7 @@ public abstract class JsonRpcServerMethod implements RequestHandler {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JSONObject transactionToJS (Transaction transaction) {
|
protected JSONObject transactionToJS (Block block, Transaction transaction) {
|
||||||
JSONObject res = new JSONObject();
|
JSONObject res = new JSONObject();
|
||||||
|
|
||||||
res.put("hash", "0x" + Hex.toHexString(transaction.getHash()));
|
res.put("hash", "0x" + Hex.toHexString(transaction.getHash()));
|
||||||
|
@ -245,13 +244,22 @@ public abstract class JsonRpcServerMethod implements RequestHandler {
|
||||||
|
|
||||||
res.put("input", "0x" + Hex.toHexString(transaction.getData()));
|
res.put("input", "0x" + Hex.toHexString(transaction.getData()));
|
||||||
|
|
||||||
/*
|
if (block == null) {
|
||||||
No way to get this data from inside of transaction.
|
res.put("transactionIndex", null);
|
||||||
TODO: Ask roman to include it into transaction class.
|
res.put("blockHash", null);
|
||||||
res.put("transactionIndex", "0x" + "");
|
res.put("blockNumber", null);
|
||||||
res.put("blockHash", "0x" + "");
|
} else {
|
||||||
res.put("blockNumber", "0x" + "");
|
long txi = 0;
|
||||||
*/
|
for (Transaction tx : block.getTransactionsList()) {
|
||||||
|
if (Arrays.equals(tx.getHash(), transaction.getHash()))
|
||||||
|
break;
|
||||||
|
txi++;
|
||||||
|
}
|
||||||
|
res.put("transactionIndex", "0x" + Long.toHexString(txi));
|
||||||
|
res.put("blockHash", "0x" + Hex.toHexString(block.getHash()));
|
||||||
|
res.put("blockNumber", "0x" + Long.toHexString(block.getNumber()));
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,20 +13,19 @@ import org.spongycastle.util.encoders.Hex;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/*
|
|
||||||
Right now LogInfo not contains information about Transaction and Transaction not have information about block.
|
|
||||||
TODO: talk to Roman about create links between LogInfo and Transaction and between Transaction and Block.
|
|
||||||
*/
|
|
||||||
public class FilterLog extends FilterBase {
|
public class FilterLog extends FilterBase {
|
||||||
|
|
||||||
private ArrayList<LogInfo> logs = new ArrayList<LogInfo>();
|
private ArrayList<FilterLogData> logs = new ArrayList<FilterLogData>();
|
||||||
|
|
||||||
long blockFrom;
|
long blockFrom;
|
||||||
long blockTo;
|
long blockTo;
|
||||||
ArrayList<byte[]> addresses = new ArrayList<>();
|
ArrayList<byte[]> addresses = new ArrayList<>();
|
||||||
ArrayList<byte[]> topics = new ArrayList<>();
|
ArrayList<byte[]> topics = new ArrayList<>();
|
||||||
|
|
||||||
|
private Ethereum ethereum;
|
||||||
|
|
||||||
public FilterLog (Ethereum ethereum, JSONObject data) {
|
public FilterLog (Ethereum ethereum, JSONObject data) {
|
||||||
|
this.ethereum = ethereum;
|
||||||
blockFrom = ethereum.getBlockchain().getBestBlock().getNumber();
|
blockFrom = ethereum.getBlockchain().getBestBlock().getNumber();
|
||||||
if (data.containsKey("fromBlock") && !((String)data.get("fromBlock")).equals("")) {
|
if (data.containsKey("fromBlock") && !((String)data.get("fromBlock")).equals("")) {
|
||||||
String fromS = (String)data.get("fromBlock");
|
String fromS = (String)data.get("fromBlock");
|
||||||
|
@ -74,16 +73,17 @@ public class FilterLog extends FilterBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
TODO: Right now Bloom from -core can be used only to check total mach of 2 same class objects. Will be nice to have possibility to check contains.
|
|
||||||
*/
|
|
||||||
public void processEvent(Object data) {
|
public void processEvent(Object data) {
|
||||||
if (data instanceof LogInfo) {
|
if (data instanceof FilterLogData) {
|
||||||
synchronized (logs) {
|
synchronized (logs) {
|
||||||
LogInfo li = (LogInfo)data;
|
FilterLogData li = (FilterLogData)data;
|
||||||
//TODO: check if li inside blockFrom - blockTo
|
if ((blockFrom >= 0 && li.block.getNumber() < blockFrom) || (blockTo >= 0 && li.block.getNumber() > blockTo))
|
||||||
|
return;
|
||||||
|
|
||||||
if (checkLogInfo(li))
|
/*
|
||||||
|
TODO: Roman must implement Bloom contain. When it will be done - we can use just Bloom.
|
||||||
|
*/
|
||||||
|
if (checkLogInfo(li.li))
|
||||||
logs.add(li);
|
logs.add(li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ TODO: Right now Bloom from -core can be used only to check total mach of 2 same
|
||||||
updateLastRequest();
|
updateLastRequest();
|
||||||
JSONArray res = new JSONArray();
|
JSONArray res = new JSONArray();
|
||||||
synchronized (logs) {
|
synchronized (logs) {
|
||||||
for(LogInfo item : logs) {
|
for(FilterLogData item : logs) {
|
||||||
res.add(logInfoToJS(item));
|
res.add(logInfoToJS(item));
|
||||||
}
|
}
|
||||||
logs.clear();
|
logs.clear();
|
||||||
|
@ -104,7 +104,6 @@ TODO: Right now Bloom from -core can be used only to check total mach of 2 same
|
||||||
public JSONArray toJS(Ethereum ethereum) {
|
public JSONArray toJS(Ethereum ethereum) {
|
||||||
JSONArray res = new JSONArray();
|
JSONArray res = new JSONArray();
|
||||||
|
|
||||||
// Process mined blocks
|
|
||||||
if (blockFrom >= 0) {
|
if (blockFrom >= 0) {
|
||||||
long i = blockFrom;
|
long i = blockFrom;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -116,7 +115,7 @@ TODO: Right now Bloom from -core can be used only to check total mach of 2 same
|
||||||
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(li));
|
res.add(logInfoToJS(new FilterLogData(block, txr, li)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,16 +123,13 @@ TODO: Right now Bloom from -core can be used only to check total mach of 2 same
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Process pending transactions. But not sure if BlockChain can return TransactionReceipt for pending transaction.
|
|
||||||
*/
|
|
||||||
if (blockFrom < 0 || blockTo < 0) {
|
if (blockFrom < 0 || blockTo < 0) {
|
||||||
for (Transaction tx : ethereum.getPendingTransactions()) {
|
for (Transaction tx : ethereum.getPendingTransactions()) {
|
||||||
TransactionReceipt txr = ethereum.getBlockchain().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(li));
|
res.add(logInfoToJS(new FilterLogData(null, txr, li)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,29 +167,63 @@ Process pending transactions. But not sure if BlockChain can return TransactionR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject logInfoToJS(LogInfo li) {
|
private JSONObject logInfoToJS(FilterLogData data) {
|
||||||
JSONObject res = new JSONObject();
|
JSONObject res = new JSONObject();
|
||||||
|
|
||||||
|
if (data.block == null) {
|
||||||
|
res.put("type", "pending");
|
||||||
|
res.put("logIndex", null);
|
||||||
|
res.put("transactionIndex", null);
|
||||||
|
res.put("transactionHash", null);
|
||||||
|
res.put("blockHash", null);
|
||||||
|
res.put("blockNumber", null);
|
||||||
|
} else {
|
||||||
|
res.put("type", "mined");
|
||||||
|
long txi = 0;
|
||||||
|
long lii = 0;
|
||||||
/*
|
/*
|
||||||
TODO: check here if log's transaction / block mined or pending.
|
TODO: for me it's a little strange way.
|
||||||
*/
|
*/
|
||||||
res.put("type", "pending");
|
for (Transaction tx : data.block.getTransactionsList()) {
|
||||||
res.put("logIndex", null);
|
for (LogInfo li : ethereum.getBlockchain().getTransactionReceiptByHash(tx.getHash()).getLogInfoList()) {
|
||||||
res.put("transactionIndex", null);
|
if (li.getBloom().equals(data.li.getBloom()))
|
||||||
res.put("transactionHash", null);
|
break;
|
||||||
res.put("blockHash", null);
|
lii++;
|
||||||
res.put("blockNumber", null);
|
}
|
||||||
|
if (Arrays.equals(tx.getHash(), data.txr.getTransaction().getHash())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
txi++;
|
||||||
|
}
|
||||||
|
res.put("logIndex", "0x" + Long.toHexString(lii));
|
||||||
|
res.put("transactionIndex", "0x" + Long.toHexString(txi));
|
||||||
|
res.put("transactionHash", "0x" + Hex.toHexString(data.txr.getTransaction().getHash()));
|
||||||
|
res.put("blockHash", "0x" + Hex.toHexString(data.block.getHash()));
|
||||||
|
res.put("blockNumber", "0x" + Long.toHexString(data.block.getNumber()));
|
||||||
|
}
|
||||||
|
|
||||||
res.put("address", Hex.toHexString(li.getAddress()));
|
res.put("address", "0x" + Hex.toHexString(data.li.getAddress()));
|
||||||
|
|
||||||
res.put("data", Hex.toHexString(li.getData()));
|
res.put("data", "0x" + Hex.toHexString(data.li.getData()));
|
||||||
|
|
||||||
JSONArray topics = new JSONArray();
|
JSONArray topics = new JSONArray();
|
||||||
for (DataWord topic : li.getTopics()) {
|
for (DataWord topic : data.li.getTopics()) {
|
||||||
topics.add(Hex.toHexString(topic.getData()));
|
topics.add("0x" + Hex.toHexString(topic.getData()));
|
||||||
}
|
}
|
||||||
res.put("topics", topics);
|
res.put("topics", topics);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class FilterLogData {
|
||||||
|
public Block block;
|
||||||
|
public TransactionReceipt txr;
|
||||||
|
public LogInfo li;
|
||||||
|
|
||||||
|
public FilterLogData( Block block, TransactionReceipt txr, LogInfo li) {
|
||||||
|
this.block = block;
|
||||||
|
this.txr = txr;
|
||||||
|
this.li = li;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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;
|
||||||
import org.ethereum.listener.EthereumListenerAdapter;
|
import org.ethereum.listener.EthereumListenerAdapter;
|
||||||
|
import org.ethereum.vm.LogInfo;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -55,6 +56,9 @@ public class FilterManager extends EthereumListenerAdapter {
|
||||||
public void onBlock(Block block, List<TransactionReceipt> receipts) {
|
public void onBlock(Block block, List<TransactionReceipt> receipts) {
|
||||||
processEvent(block);
|
processEvent(block);
|
||||||
for(TransactionReceipt tx : receipts) {
|
for(TransactionReceipt tx : receipts) {
|
||||||
|
for (LogInfo li : tx.getLogInfoList()) {
|
||||||
|
processEvent(new FilterLog.FilterLogData(block, tx, li));
|
||||||
|
}
|
||||||
processEvent(tx.getTransaction());
|
processEvent(tx.getTransaction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,8 @@ import org.ethereum.core.*;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Present big issue - current ethereumj-core not have coinbase "functionality".
|
TODO: -core not handle mining so coinbase not present in it. Right now returned second address from Wallet. Must be changed in app where implemented mining
|
||||||
On each app start - it create 2 addresses: "cow", coinbase.secret ("monkey") --- WorldManager.java -> init
|
|
||||||
Also because not present mining functionality - no wat to identify what address will be coinbase (mining success payment place to)
|
|
||||||
TODO: change this after fix in ethereumj-core
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class eth_coinbase extends JsonRpcServerMethod {
|
public class eth_coinbase extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_coinbase (Ethereum ethereum) {
|
public eth_coinbase (Ethereum ethereum) {
|
||||||
|
|
|
@ -13,8 +13,7 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Example taken from -studio. Not sure if we must call encodeMachineCodeForVMRun in end
|
TODO: Serpent will be depricated in future.
|
||||||
TODO: get advice from Roman about encodeMachineCodeForVMRun
|
|
||||||
*/
|
*/
|
||||||
public class eth_compileSerpent extends JsonRpcServerMethod {
|
public class eth_compileSerpent extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
@ -41,7 +40,7 @@ public class eth_compileSerpent extends JsonRpcServerMethod {
|
||||||
} else {
|
} else {
|
||||||
asmResult = SerpentCompiler.compile(code);
|
asmResult = SerpentCompiler.compile(code);
|
||||||
machineCode = SerpentCompiler.compileAssemblyToMachine(asmResult);
|
machineCode = SerpentCompiler.compileAssemblyToMachine(asmResult);
|
||||||
// machineCode = SerpentCompiler.encodeMachineCodeForVMRun(machineCode, null);
|
machineCode = SerpentCompiler.encodeMachineCodeForVMRun(machineCode, null);
|
||||||
}
|
}
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID());
|
return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID());
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: -core not have solidity compiler
|
ATODO: -core not have solidity compiler. Need try to use cpp solidity compiler using JNI
|
||||||
*/
|
*/
|
||||||
public class eth_compileSolidity extends JsonRpcServerMethod {
|
public class eth_compileSolidity extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,6 @@ import org.spongycastle.util.encoders.Hex;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
|
||||||
By specification this method can receive hash of pending block but from -core it's not possible.
|
|
||||||
TODO: get advice from Roman about pending block
|
|
||||||
*/
|
|
||||||
public class eth_getBlockByHash extends JsonRpcServerMethod {
|
public class eth_getBlockByHash extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_getBlockByHash (Ethereum ethereum) {
|
public eth_getBlockByHash (Ethereum ethereum) {
|
||||||
|
|
|
@ -10,10 +10,6 @@ import org.spongycastle.util.encoders.Hex;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
|
||||||
By specification this method can receive number of pending block but from -core it's not possible.
|
|
||||||
TODO: get advice from Roman about pending block
|
|
||||||
*/
|
|
||||||
public class eth_getBlockByNumber extends JsonRpcServerMethod {
|
public class eth_getBlockByNumber extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_getBlockByNumber (Ethereum ethereum) {
|
public eth_getBlockByNumber (Ethereum ethereum) {
|
||||||
|
@ -33,8 +29,9 @@ public class eth_getBlockByNumber extends JsonRpcServerMethod {
|
||||||
if (blockNumber == -1) {
|
if (blockNumber == -1) {
|
||||||
blockNumber = ethereum.getBlockchain().getBestBlock().getNumber();
|
blockNumber = ethereum.getBlockchain().getBestBlock().getNumber();
|
||||||
}
|
}
|
||||||
// TODO: here we must load pending block but -core not "group" it.
|
|
||||||
if (blockNumber == -2) {
|
if (blockNumber == -2) {
|
||||||
|
return new JSONRPC2Response(null, req.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = ethereum.getBlockchain().getBlockByNumber(blockNumber);
|
Block block = ethereum.getBlockchain().getBlockByNumber(blockNumber);
|
||||||
|
|
|
@ -7,10 +7,6 @@ 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;
|
||||||
|
|
||||||
/*
|
|
||||||
Not sure if pending can have code. Also code by itself related to repository not very clear for me.
|
|
||||||
TODO: ask Roman advice for this method.
|
|
||||||
*/
|
|
||||||
public class eth_getCode extends JsonRpcServerMethod {
|
public class eth_getCode extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_getCode (Ethereum ethereum) {
|
public eth_getCode (Ethereum ethereum) {
|
||||||
|
|
|
@ -16,7 +16,9 @@ public class eth_getCompilers extends JsonRpcServerMethod {
|
||||||
|
|
||||||
ArrayList<String> tmp = new ArrayList<String>();
|
ArrayList<String> tmp = new ArrayList<String>();
|
||||||
tmp.add("serpent");
|
tmp.add("serpent");
|
||||||
//TODO: add lll and solidity when they will be implemented in -core
|
/*
|
||||||
|
TODO: add lll and solidity when we find good libs for them. They not planned to be implemented in -core.
|
||||||
|
*/
|
||||||
JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(tmp, req.getID());
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,6 @@ import org.ethereum.vm.DataWord;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
|
||||||
As I see getStorageValue not check Pending Transactions.
|
|
||||||
TODO: ask roman advice for this method.
|
|
||||||
*/
|
|
||||||
public class eth_getStorageAt extends JsonRpcServerMethod {
|
public class eth_getStorageAt extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_getStorageAt(Ethereum ethereum) { super(ethereum); }
|
public eth_getStorageAt(Ethereum ethereum) { super(ethereum); }
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class eth_getTransactionByBlockHashAndIndex extends JsonRpcServerMethod {
|
||||||
if (block.getTransactionsList().size() <= index)
|
if (block.getTransactionsList().size() <= index)
|
||||||
return new JSONRPC2Response(null, req.getID());
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
|
||||||
JSONObject tx = transactionToJS(block.getTransactionsList().get(index));
|
JSONObject tx = transactionToJS(block, block.getTransactionsList().get(index));
|
||||||
tx.put("transactionIndex", "0x" + Integer.toHexString(index));
|
tx.put("transactionIndex", "0x" + Integer.toHexString(index));
|
||||||
tx.put("blockHash", "0x" + Hex.toHexString(block.getHash()));
|
tx.put("blockHash", "0x" + Hex.toHexString(block.getHash()));
|
||||||
tx.put("blockNumber", "0x" + Long.toHexString(block.getNumber()));
|
tx.put("blockNumber", "0x" + Long.toHexString(block.getNumber()));
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minidev.json.JSONObject;
|
||||||
import org.ethereum.android.jsonrpc.JsonRpcServerMethod;
|
import org.ethereum.android.jsonrpc.JsonRpcServerMethod;
|
||||||
import org.ethereum.core.AccountState;
|
import org.ethereum.core.AccountState;
|
||||||
import org.ethereum.core.Block;
|
import org.ethereum.core.Block;
|
||||||
|
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;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
@ -32,23 +33,22 @@ public class eth_getTransactionByBlockNumberAndIndex extends JsonRpcServerMethod
|
||||||
if (blockNumber == -1) {
|
if (blockNumber == -1) {
|
||||||
blockNumber = ethereum.getBlockchain().getBestBlock().getNumber();
|
blockNumber = ethereum.getBlockchain().getBestBlock().getNumber();
|
||||||
}
|
}
|
||||||
// TODO: here we must load pending block but -core not "group" it.
|
|
||||||
|
Block block = null;
|
||||||
|
JSONObject tx = null;
|
||||||
if (blockNumber == -2) {
|
if (blockNumber == -2) {
|
||||||
|
if (ethereum.getPendingTransactions().size() <= index)
|
||||||
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
tx = transactionToJS(null, (Transaction)ethereum.getPendingTransactions().toArray()[index]);
|
||||||
|
} else {
|
||||||
|
block = ethereum.getBlockchain().getBlockByNumber(blockNumber);
|
||||||
|
if (block == null)
|
||||||
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
if (block.getTransactionsList().size() <= index)
|
||||||
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
tx = transactionToJS(block, block.getTransactionsList().get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = ethereum.getBlockchain().getBlockByNumber(blockNumber);
|
|
||||||
|
|
||||||
if (block == null)
|
|
||||||
return new JSONRPC2Response(null, req.getID());
|
|
||||||
|
|
||||||
if (block.getTransactionsList().size() <= index)
|
|
||||||
return new JSONRPC2Response(null, req.getID());
|
|
||||||
|
|
||||||
JSONObject tx = transactionToJS(block.getTransactionsList().get(index));
|
|
||||||
tx.put("transactionIndex", "0x" + Integer.toHexString(index));
|
|
||||||
tx.put("blockHash", "0x" + Hex.toHexString(block.getHash()));
|
|
||||||
tx.put("blockNumber", "0x" + Long.toHexString(block.getNumber()));
|
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(tx, req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(tx, req.getID());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ import org.ethereum.core.TransactionReceipt;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/*
|
||||||
|
ATODO: talk with Adrian to get relation between Transaction and Block from db.
|
||||||
|
*/
|
||||||
public class eth_getTransactionByHash extends JsonRpcServerMethod {
|
public class eth_getTransactionByHash extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_getTransactionByHash (Ethereum ethereum) {
|
public eth_getTransactionByHash (Ethereum ethereum) {
|
||||||
|
@ -26,7 +29,7 @@ public class eth_getTransactionByHash extends JsonRpcServerMethod {
|
||||||
if (transaction == null)
|
if (transaction == null)
|
||||||
return new JSONRPC2Response(null, req.getID());
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(transactionToJS(transaction.getTransaction()), req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(transactionToJS(null, transaction.getTransaction()), req.getID());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class eth_getUncleByBlockHashAndIndex extends JsonRpcServerMethod {
|
||||||
if (block.getUncleList().size() <= index)
|
if (block.getUncleList().size() <= index)
|
||||||
return new JSONRPC2Response(null, req.getID());
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
|
||||||
Block uncle = ethereum.getBlockchain().getBlockByHash(HashUtil.sha3(block.getUncleList().get(index).getEncoded()));
|
Block uncle = new Block(block.getUncleList().get(index), null, null);
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(blockToJS(uncle, false), req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(blockToJS(uncle, false), req.getID());
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.ethereum.crypto.HashUtil;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class eth_getUncleByBlockNumberAndIndex extends JsonRpcServerMethod {
|
public class eth_getUncleByBlockNumberAndIndex extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_getUncleByBlockNumberAndIndex (Ethereum ethereum) {
|
public eth_getUncleByBlockNumberAndIndex (Ethereum ethereum) {
|
||||||
|
@ -27,7 +28,7 @@ public class eth_getUncleByBlockNumberAndIndex extends JsonRpcServerMethod {
|
||||||
if (blockNumber == -1) {
|
if (blockNumber == -1) {
|
||||||
blockNumber = ethereum.getBlockchain().getBestBlock().getNumber();
|
blockNumber = ethereum.getBlockchain().getBestBlock().getNumber();
|
||||||
}
|
}
|
||||||
// TODO: here we must load pending block but -core not "group" it.
|
|
||||||
if (blockNumber == -2) {
|
if (blockNumber == -2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ public class eth_getUncleByBlockNumberAndIndex extends JsonRpcServerMethod {
|
||||||
if (block.getUncleList().size() <= index)
|
if (block.getUncleList().size() <= index)
|
||||||
return new JSONRPC2Response(null, req.getID());
|
return new JSONRPC2Response(null, req.getID());
|
||||||
|
|
||||||
Block uncle = ethereum.getBlockchain().getBlockByHash(HashUtil.sha3(block.getUncleList().get(index).getEncoded()));
|
Block uncle = new Block(block.getUncleList().get(index), null, null);
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(blockToJS(uncle, false), req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(blockToJS(uncle, false), req.getID());
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.ethereum.android.jsonrpc.JsonRpcServerMethod;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: right now -core not auto start mining so no way to get information about state
|
TODO: must be changed in app that implement mining
|
||||||
*/
|
*/
|
||||||
public class eth_getWork extends JsonRpcServerMethod {
|
public class eth_getWork extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.ethereum.android.jsonrpc.JsonRpcServerMethod;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: right now -core not have "finished" mining architecture so not have hashrate
|
TODO: must be changed in app that implement mining
|
||||||
*/
|
*/
|
||||||
public class eth_hashrate extends JsonRpcServerMethod {
|
public class eth_hashrate extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.ethereum.android.jsonrpc.JsonRpcServerMethod;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: right now -core not auto start mining and also not have marker to identify if it's happening
|
TODO: must be changed in app that implement mining
|
||||||
*/
|
*/
|
||||||
public class eth_mining extends JsonRpcServerMethod {
|
public class eth_mining extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ import java.util.concurrent.TimeUnit;
|
||||||
import static org.ethereum.core.Denomination.SZABO;
|
import static org.ethereum.core.Denomination.SZABO;
|
||||||
import static org.ethereum.config.SystemProperties.CONFIG;
|
import static org.ethereum.config.SystemProperties.CONFIG;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: get more information from Roman, he think about this right now about 20 - 32 result.
|
||||||
|
*/
|
||||||
public class eth_sendTransaction extends JsonRpcServerMethod {
|
public class eth_sendTransaction extends JsonRpcServerMethod {
|
||||||
|
|
||||||
public eth_sendTransaction (Ethereum ethereum) {
|
public eth_sendTransaction (Ethereum ethereum) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.ethereum.facade.Ethereum;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: right now -core not auto start mining so no way to get information about state
|
TODO: must be changed in app that implement mining
|
||||||
*/
|
*/
|
||||||
public class eth_submitWork extends JsonRpcServerMethod {
|
public class eth_submitWork extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.ethereum.android.jsonrpc.JsonRpcServerMethod;
|
||||||
import org.ethereum.facade.Ethereum;
|
import org.ethereum.facade.Ethereum;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: request go version how this must be identified. Cpp version just return "".
|
TODO: maybe in future AdminState will have information about this.
|
||||||
*/
|
*/
|
||||||
public class net_version extends JsonRpcServerMethod {
|
public class net_version extends JsonRpcServerMethod {
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class shh_post extends JsonRpcServerMethod {
|
||||||
|
|
||||||
int ttl = jsToInt((String)obj.get("ttl"));
|
int ttl = jsToInt((String)obj.get("ttl"));
|
||||||
|
|
||||||
//TODO:
|
//TODO: implement after Adrian merge with dev
|
||||||
|
|
||||||
JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
|
JSONRPC2Response res = new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processEvent(Object data) {
|
public void processEvent(Object data) {
|
||||||
//TODO: parse incomming data when we will know what comes.
|
//TODO: parse incomming data when we will know what comes.
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONArray toJS() {
|
public JSONArray toJS() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.TimerTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This class must receive notification from -core about new whisper message. Right now I not see the way todo that.
|
This class must receive notification from -core about new whisper message. Right now I not see the way to do that.
|
||||||
TODO: ask advice from Roman about how to send notification to this class.
|
TODO: ask advice from Roman about how to send notification to this class.
|
||||||
*/
|
*/
|
||||||
public class FilterManager {
|
public class FilterManager {
|
||||||
|
|
Loading…
Reference in New Issue