Search in sources :

Example 6 with IAionBlock

use of org.aion.zero.types.IAionBlock 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;
}
Also used : AionBlockSummary(org.aion.zero.impl.types.AionBlockSummary) Log(org.aion.mcf.vm.types.Log) Bloom(org.aion.mcf.vm.types.Bloom) IAionBlock(org.aion.zero.types.IAionBlock) AionTxReceipt(org.aion.zero.types.AionTxReceipt)

Example 7 with IAionBlock

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

the class EquihashMiner method mine.

/**
 * Keeps mining until the thread is interrupted
 */
protected void mine() {
    IAionBlock block;
    byte[] nonce;
    while (!Thread.currentThread().isInterrupted()) {
        if ((block = miningBlock) == null) {
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                break;
            }
        } else {
            // A new array must be created each loop
            // If reference is reused the array contents may be changed
            // before block sealed causing validation to fail
            nonce = new byte[32];
            ThreadLocalRandom.current().nextBytes(nonce);
            Solution s = miner.mine(block, nonce);
            if (s != null) {
                IEvent ev = new EventConsensus(EventConsensus.CALLBACK.ON_SOLUTION);
                ev.setFuncArgs(Collections.singletonList(s));
                evtMgr.newEvent(ev);
            }
        }
    }
}
Also used : IEvent(org.aion.evtmgr.IEvent) IAionBlock(org.aion.zero.types.IAionBlock) EventConsensus(org.aion.evtmgr.impl.evt.EventConsensus)

Example 8 with IAionBlock

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

the class AionBlockStore method getListHashesEndWith.

@Override
public List<byte[]> getListHashesEndWith(byte[] hash, long number) {
    List<AionBlock> blocks = getListBlocksEndWith(hash, number);
    List<byte[]> hashes = new ArrayList<>(blocks.size());
    for (IAionBlock b : blocks) {
        hashes.add(b.getHash());
    }
    return hashes;
}
Also used : IAionBlock(org.aion.zero.types.IAionBlock) ArrayList(java.util.ArrayList) AionBlock(org.aion.zero.impl.types.AionBlock) IAionBlock(org.aion.zero.types.IAionBlock)

Aggregations

IAionBlock (org.aion.zero.types.IAionBlock)8 ArrayList (java.util.ArrayList)2 AionBlock (org.aion.zero.impl.types.AionBlock)2 BigInteger (java.math.BigInteger)1 IEvent (org.aion.evtmgr.IEvent)1 EventConsensus (org.aion.evtmgr.impl.evt.EventConsensus)1 Bloom (org.aion.mcf.vm.types.Bloom)1 Log (org.aion.mcf.vm.types.Log)1 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)1 A0BlockHeader (org.aion.zero.types.A0BlockHeader)1 AionTxReceipt (org.aion.zero.types.AionTxReceipt)1