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()));
}
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;
}
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();
}
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());
}
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());
}
}
}
Aggregations