use of org.aion.api.server.types.EvtContract 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()) {
if (LOG.isDebugEnabled()) {
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();
AionAddress contractAddress = Optional.ofNullable(tx.getDestinationAddress()).orElse(TxUtil.calculateContractAddress(tx));
Integer cnt = 0;
txr.getLogInfoList().forEach(bi -> bi.copyOfTopics().forEach(lg -> {
if (_fltr.isFor(contractAddress, ByteUtil.toHexString(lg))) {
Block blk = (cbs).getBlock();
List<AionTransaction> txList = blk.getTransactionsList();
int insideCnt = 0;
for (AionTransaction t : txList) {
if (Arrays.equals(t.getTransactionHash(), tx.getTransactionHash())) {
break;
}
insideCnt++;
}
EvtContract ec = new EvtContract(bi.copyOfAddress(), bi.copyOfData(), blk.getHash(), blk.getNumber(), cnt, ByteUtil.toHexString(lg), false, insideCnt, tx.getTransactionHash());
_fltr.add(ec);
}
}));
}
}
}
}
}
Aggregations