Search in sources :

Example 1 with EventExecuteService

use of org.aion.evtmgr.impl.es.EventExecuteService in project aion by aionnetwork.

the class ApiAion method startES.

protected void startES(String thName) {
    ees = new EventExecuteService(100_000, thName, Thread.MIN_PRIORITY, LOG);
    ees.setFilter(setEvtfilter());
    ees.start(new EpApi());
}
Also used : EventExecuteService(org.aion.evtmgr.impl.es.EventExecuteService)

Example 2 with EventExecuteService

use of org.aion.evtmgr.impl.es.EventExecuteService in project aion by aionnetwork.

the class AionPendingStateImpl method init.

public void init(final AionBlockchainImpl blockchain) {
    this.blockchain = blockchain;
    this.transactionStore = blockchain.getTransactionStore();
    this.evtMgr = blockchain.getEventMgr();
    this.pendingTxCache = new PendingTxCache(CfgAion.inst().getTx().getCacheMax());
    this.pendingState = repository.startTracking();
    ees = new EventExecuteService(1000, "EpPS", Thread.MAX_PRIORITY, LOG);
    ees.setFilter(setEvtFilter());
    regBlockEvents();
    IHandler blkHandler = this.evtMgr.getHandler(2);
    if (blkHandler != null) {
        blkHandler.eventCallback(new EventCallback(ees, LOG));
    }
    ees.start(new EpPS());
}
Also used : EventExecuteService(org.aion.evtmgr.impl.es.EventExecuteService) IHandler(org.aion.evtmgr.IHandler) EventCallback(org.aion.evtmgr.impl.callback.EventCallback)

Example 3 with EventExecuteService

use of org.aion.evtmgr.impl.es.EventExecuteService in project aion by aionnetwork.

the class AionPoW method init.

/**
 * Initializes this instance.
 *
 * @param blockchain
 *            Aion blockchain instance
 * @param pendingState
 *            List of Aion transactions
 * @param eventMgr
 *            Event manager
 */
public void init(IAionBlockchain blockchain, IPendingState<AionTransaction> pendingState, IEventMgr eventMgr) {
    if (initialized.compareAndSet(false, true)) {
        this.blockchain = blockchain;
        this.pendingState = pendingState;
        this.eventMgr = eventMgr;
        this.syncMgr = SyncMgr.inst();
        setupHandler();
        ees = new EventExecuteService(100_000, "EpPow", Thread.NORM_PRIORITY, LOG);
        ees.setFilter(setEvtFilter());
        registerCallback();
        ees.start(new EpPOW());
        new Thread(() -> {
            while (!shutDown.get()) {
                try {
                    Thread.sleep(100);
                    long now = System.currentTimeMillis();
                    if (now - lastUpdate.get() > 3000 && newPendingTxReceived.compareAndSet(true, false) || now - lastUpdate.get() > 10000) {
                        // fallback, when
                        // we never
                        // received any
                        // events
                        createNewBlockTemplate();
                    }
                } catch (InterruptedException e) {
                    break;
                }
            }
        }, "pow").start();
    }
}
Also used : EventExecuteService(org.aion.evtmgr.impl.es.EventExecuteService)

Aggregations

EventExecuteService (org.aion.evtmgr.impl.es.EventExecuteService)3 IHandler (org.aion.evtmgr.IHandler)1 EventCallback (org.aion.evtmgr.impl.callback.EventCallback)1