get transaction relation using -core-android custom OrmLiteBlockStoreDatabase

This commit is contained in:
Yaroslav Dmytrotsa 2015-06-29 12:30:43 +03:00
parent bc91b5f13b
commit ae517f349b
2 changed files with 13 additions and 7 deletions

View File

@ -6,6 +6,8 @@ import com.thetransactioncompany.jsonrpc2.server.*;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import org.ethereum.android.db.BlockTransactionVO;
import org.ethereum.android.db.OrmLiteBlockStoreDatabase;
import org.ethereum.android.jsonrpc.JsonRpcServer;
import org.ethereum.core.Account;
import org.ethereum.core.AccountState;
@ -245,10 +247,17 @@ public abstract class JsonRpcServerMethod implements RequestHandler {
res.put("input", "0x" + Hex.toHexString(transaction.getData()));
if (block == null) {
OrmLiteBlockStoreDatabase db = OrmLiteBlockStoreDatabase.getHelper(null);
BlockTransactionVO relation = db.getTransactionLocation(transaction.getHash());
if (relation == null) {
res.put("transactionIndex", null);
res.put("blockHash", null);
res.put("blockNumber", null);
} else {
block = ethereum.getBlockchain().getBlockByHash(relation.getBlockHash());
}
}
if (block != null) {
long txi = 0;
for (Transaction tx : block.getTransactionsList()) {
if (Arrays.equals(tx.getHash(), transaction.getHash()))

View File

@ -7,9 +7,6 @@ import org.ethereum.core.TransactionReceipt;
import org.ethereum.facade.Ethereum;
import java.util.List;
/*
ATODO: talk with Adrian to get relation between Transaction and Block from db.
*/
public class eth_getTransactionByHash extends JsonRpcServerMethod {
public eth_getTransactionByHash (Ethereum ethereum) {