Search in sources :

Example 6 with AionTxReceipt

use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.

the class Tx method InfoToJSON.

public static Object InfoToJSON(AionTxInfo info, AionBlock b) {
    if (info == null)
        return null;
    AionTxReceipt receipt = info.getReceipt();
    if (receipt == null)
        return null;
    AionTransaction tx = receipt.getTransaction();
    return (AionTransactionToJSON(tx, b, info.getIndex()));
}
Also used : AionTransaction(org.aion.zero.types.AionTransaction) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Example 7 with AionTxReceipt

use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.

the class FltrLg method onBlock.

// inelegant (distributing chain singleton ref. into here), tradeoff for efficiency and ease of impl.
// rationale: this way, we only retrieve logs from DB for transactions that the bloom
// filter gives a positive match for;
public boolean onBlock(IAionBlock blk, IAionBlockchain chain) {
    if (matchBloom(new Bloom(blk.getLogBloom()))) {
        int txIndex = 0;
        for (ITransaction txn : blk.getTransactionsList()) {
            if (matchesContractAddress(txn.getTo().toBytes())) {
                // now that we know that our filter might match with some logs in this transaction, go ahead
                // and retrieve the txReceipt from the chain
                AionTxInfo txInfo = chain.getTransactionInfo(txn.getHash());
                AionTxReceipt receipt = txInfo.getReceipt();
                if (matchBloom(receipt.getBloomFilter())) {
                    int logIndex = 0;
                    for (Log logInfo : receipt.getLogInfoList()) {
                        if (matchBloom(logInfo.getBloom()) && matchesExactly(logInfo)) {
                            add(new EvtLg(new TxRecptLg(logInfo, blk, txIndex, txn, logIndex, true)));
                        }
                        logIndex++;
                    }
                }
            }
            txIndex++;
        }
    }
    return true;
}
Also used : AionTxInfo(org.aion.zero.impl.types.AionTxInfo) Log(org.aion.mcf.vm.types.Log) Bloom(org.aion.mcf.vm.types.Bloom) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Example 8 with AionTxReceipt

use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.

the class ApiWeb3Aion method eth_getTransactionReceipt.

public Object eth_getTransactionReceipt(String _txHash) {
    byte[] txHash = TypeConverter.StringHexToByteArray(_txHash);
    TxRecpt r = getTransactionReceipt(txHash);
    // if we can't find the receipt on the mainchain, try looking for it in pending receipts cache
    if (r == null) {
        AionTxReceipt pendingReceipt = pendingReceipts.get(new ByteArrayWrapper(txHash));
        r = new TxRecpt(pendingReceipt, null, null, null, true);
    }
    if (r == null)
        return null;
    return r.toJson();
}
Also used : ByteArrayWrapper(org.aion.base.util.ByteArrayWrapper) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Example 9 with AionTxReceipt

use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.

the class ApiWeb3Aion method eth_call.

public Object eth_call(JSONObject _tx, Object _bnOrId) {
    ArgTxCall txParams = ArgTxCall.fromJSON(_tx, getRecommendedNrgPrice(), getDefaultNrgLimit());
    String bnOrId = "latest";
    if (_bnOrId != null && !_bnOrId.equals(null))
        bnOrId = _bnOrId + "";
    Long bn = parseBnOrId(bnOrId);
    if (bn == null || bn < 0)
        return null;
    AionTransaction tx = new AionTransaction(txParams.getNonce().toByteArray(), txParams.getTo(), txParams.getValue().toByteArray(), txParams.getData(), txParams.getNrg(), txParams.getNrgPrice());
    AionBlock b = this.ac.getBlockchain().getBlockByNumber(bn);
    AionTxReceipt receipt = this.ac.callConstant(tx, b);
    return TypeConverter.toJsonHex(receipt.getExecutionResult());
}
Also used : AionTransaction(org.aion.zero.types.AionTransaction) ByteUtil.toHexString(org.aion.base.util.ByteUtil.toHexString) AionTxReceipt(org.aion.zero.types.AionTxReceipt) AionBlock(org.aion.zero.impl.types.AionBlock)

Example 10 with AionTxReceipt

use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.

the class ApiAion0 method pendingTxUpdate.

protected void pendingTxUpdate(ITxReceipt _txRcpt, EventTx.STATE _state) {
    ByteArrayWrapper txHashW = new ByteArrayWrapper(((AionTxReceipt) _txRcpt).getTransaction().getHash());
    if (LOG.isDebugEnabled()) {
        LOG.debug("ApiAionA0.onPendingTransactionUpdate - txHash: [{}], state: [{}]", txHashW.toString(), _state.getValue());
    }
    if (getMsgIdMapping().get(txHashW) != null) {
        if (pendingStatus.remainingCapacity() == 0) {
            pendingStatus.poll();
            LOG.warn("ApiAionA0.onPendingTransactionUpdate - txPend ingStatus queue full, drop the first message.");
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("ApiAionA0.onPendingTransactionUpdate - the pending Tx state : [{}]", _state.getValue());
        }
        pendingStatus.add(new TxPendingStatus(txHashW, getMsgIdMapping().get(txHashW).getValue(), getMsgIdMapping().get(txHashW).getKey(), _state.getValue(), ByteArrayWrapper.wrap(((AionTxReceipt) _txRcpt).getExecutionResult() == null ? ByteUtil.EMPTY_BYTE_ARRAY : ((AionTxReceipt) _txRcpt).getExecutionResult())));
        if (_state.isPending()) {
            pendingReceipts.put(txHashW, ((AionTxReceipt) _txRcpt));
        } else {
            pendingReceipts.remove(txHashW);
            getMsgIdMapping().remove(txHashW);
        }
    } else {
        if (txWait.remainingCapacity() == 0) {
            txWait.poll();
            if (LOG.isDebugEnabled()) {
                LOG.debug("ApiAionA0.onPendingTransactionUpdate - txWait queue full, drop the first message.");
            }
        }
        // waiting origin Api call status been callback
        try {
            txWait.put(new TxWaitingMappingUpdate(txHashW, _state.getValue(), ((AionTxReceipt) _txRcpt)));
        } catch (InterruptedException e) {
            LOG.error("ApiAionA0.onPendingTransactionUpdate txWait.put exception", e.getMessage());
        }
    }
}
Also used : ByteArrayWrapper(org.aion.base.util.ByteArrayWrapper) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Aggregations

AionTxReceipt (org.aion.zero.types.AionTxReceipt)11 AionTransaction (org.aion.zero.types.AionTransaction)6 ByteArrayWrapper (org.aion.base.util.ByteArrayWrapper)3 Bloom (org.aion.mcf.vm.types.Bloom)3 Log (org.aion.mcf.vm.types.Log)3 AionBlock (org.aion.zero.impl.types.AionBlock)2 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)2 AionTxInfo (org.aion.zero.impl.types.AionTxInfo)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 BigInteger (java.math.BigInteger)1 ByteBuffer (java.nio.ByteBuffer)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 Collectors (java.util.stream.Collectors)1 LongStream (java.util.stream.LongStream)1 ApiAion (org.aion.api.server.ApiAion)1