use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.
the class ApiAion method doCall.
public byte[] doCall(ArgTxCall _params) {
AionTransaction tx = new AionTransaction(_params.getNonce().toByteArray(), _params.getTo(), _params.getValue().toByteArray(), _params.getData(), _params.getNrg(), _params.getNrgPrice());
AionTxReceipt rec = this.ac.callConstant(tx, this.ac.getAionHub().getBlockchain().getBestBlock());
return rec.getExecutionResult();
}
use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.
the class ApiAion method estimateGas.
public long estimateGas(ArgTxCall params) {
AionTransaction tx = new AionTransaction(params.getNonce().toByteArray(), params.getTo(), params.getValue().toByteArray(), params.getData(), params.getNrg(), params.getNrgPrice());
AionTxReceipt receipt = this.ac.callConstant(tx, this.ac.getAionHub().getBlockchain().getBestBlock());
return receipt.getEnergyUsed();
}
use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.
the class ApiAion0 method onBlock.
protected void onBlock(AionBlockSummary cbs) {
Set<Long> keys = installedFilters.keySet();
for (Long key : keys) {
Fltr fltr = installedFilters.get(key);
if (fltr.isExpired()) {
LOG.debug("<fltr key={} expired removed>", key);
installedFilters.remove(key);
} else {
List<AionTxReceipt> txrs = cbs.getReceipts();
if (fltr.getType() == Fltr.Type.EVENT && !Optional.ofNullable(txrs).orElse(Collections.emptyList()).isEmpty()) {
FltrCt _fltr = (FltrCt) fltr;
for (AionTxReceipt txr : txrs) {
AionTransaction tx = txr.getTransaction();
Address contractAddress = Optional.ofNullable(tx.getTo()).orElse(tx.getContractAddress());
Integer cnt = 0;
txr.getLogInfoList().forEach(bi -> bi.getTopics().forEach(lg -> {
if (_fltr.isFor(contractAddress, ByteUtil.toHexString(lg))) {
IBlock<AionTransaction, ?> blk = (cbs).getBlock();
List<AionTransaction> txList = blk.getTransactionsList();
int insideCnt = 0;
for (AionTransaction t : txList) {
if (Arrays.equals(t.getHash(), tx.getHash())) {
break;
}
insideCnt++;
}
EvtContract ec = new EvtContract(bi.getAddress().toBytes(), bi.getData(), blk.getHash(), blk.getNumber(), cnt, ByteUtil.toHexString(lg), false, insideCnt, tx.getHash());
_fltr.add(ec);
}
}));
}
}
}
}
}
use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.
the class AionTxReceiptTest method testSerialization.
@Test
public void testSerialization() {
AionTxReceipt receipt = new AionTxReceipt();
receipt.setError("");
receipt.setExecutionResult(HashUtil.h256(EMPTY_BYTE_ARRAY));
List<Log> infos = new ArrayList<>();
receipt.setLogs(infos);
receipt.setPostTxState(HashUtil.h256(EMPTY_BYTE_ARRAY));
byte[] encoded = receipt.getEncoded();
AionTxReceipt resp = new AionTxReceipt(encoded);
assertThat(resp.getExecutionResult(), is(equalTo(receipt.getExecutionResult())));
assertThat(resp.getBloomFilter(), is(equalTo(receipt.getBloomFilter())));
assertThat(resp.getError(), is(equalTo(receipt.getError())));
}
use of org.aion.zero.types.AionTxReceipt in project aion by aionnetwork.
the class FltrLg method onBlock.
// -------------------------------------------------------------------------------
@Override
public boolean onBlock(IBlockSummary bs) {
List<AionTxReceipt> receipts = ((AionBlockSummary) bs).getReceipts();
IBlock blk = bs.getBlock();
if (matchBloom(new Bloom(((IAionBlock) blk).getLogBloom()))) {
int txIndex = 0;
for (AionTxReceipt receipt : receipts) {
ITransaction tx = receipt.getTransaction();
if (matchesContractAddress(tx.getTo().toBytes())) {
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, receipt.getTransaction(), logIndex, true)));
}
logIndex++;
}
}
}
txIndex++;
}
}
return true;
}
Aggregations