Skip to content

Commit

Permalink
AKI-608 Removed eventMgr in the pendingState
Browse files Browse the repository at this point in the history
  • Loading branch information
AionJayT committed Dec 18, 2019
1 parent 0a5c774 commit ac7bab1
Showing 1 changed file with 0 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
import org.aion.base.AionTransaction;
import org.aion.base.PooledTransaction;
import org.aion.base.TxUtil;
import org.aion.evtmgr.IEvent;
import org.aion.evtmgr.IEventMgr;
import org.aion.evtmgr.IHandler;
import org.aion.evtmgr.impl.callback.EventCallback;
import org.aion.evtmgr.impl.es.EventExecuteService;
import org.aion.evtmgr.impl.evt.EventBlock;
import org.aion.evtmgr.impl.evt.EventTx;
import org.aion.log.AionLoggerFactory;
import org.aion.log.LogEnum;
import org.aion.mcf.blockchain.Block;
Expand Down Expand Up @@ -108,16 +101,12 @@ public TransactionSortedSet() {

private final ITxPool txPool;

private IEventMgr evtMgr = null;

private RepositoryCache<AccountState> pendingState;

private AtomicReference<Block> best;

private PendingTxCache pendingTxCache;

private EventExecuteService ees;

private List<AionTxExecSummary> txBuffer;

/**
Expand Down Expand Up @@ -218,31 +207,6 @@ private synchronized void processTxBuffer() {
}
}

private final class EpPS implements Runnable {

boolean go = true;

/**
* When an object implementing interface <code>Runnable</code> is used to create a thread,
* starting the thread causes the object's <code>run</code> method to be called in that
* separately executing thread.
*
* <p>The general contract of the method <code>run</code> is that it may take any action
* whatsoever.
*
* @see Thread#run()
*/
@Override
public void run() {
while (go) {
IEvent e = ees.take();
if (e.getEventType() == IHandler.TYPE.POISONPILL.getValue()) {
go = false;
}
}
}
}

private synchronized void backupPendingTx() {

if (!backupPendingPoolAdd.isEmpty()) {
Expand Down Expand Up @@ -320,7 +284,6 @@ public void init(final AionBlockchainImpl blockchain, boolean test) {
if (!this.isSeed) {
this.transactionStore = blockchain.getTransactionStore();

this.evtMgr = blockchain.getEventMgr();
this.poolBackUpEnable = CfgAion.inst().getTx().getPoolBackup();
this.replayTxBuffer = new ArrayList<>();
this.pendingTxCache =
Expand All @@ -329,14 +292,6 @@ public void init(final AionBlockchainImpl blockchain, boolean test) {

this.dumpPool = test || CfgAion.inst().getTx().getPoolDump();

ees = new EventExecuteService(1000, "EpPS", Thread.MAX_PRIORITY, LOGGER_TX);
ees.setFilter(setEvtFilter());

IHandler blkHandler = this.evtMgr.getHandler(IHandler.TYPE.BLOCK0.getValue());
if (blkHandler != null) {
blkHandler.eventCallback(new EventCallback(ees, LOGGER_TX));
}

if (poolBackUpEnable) {
this.backupPendingPoolAdd = new HashMap<>();
this.backupPendingCacheAdd = new HashMap<>();
Expand All @@ -351,25 +306,7 @@ public void init(final AionBlockchainImpl blockchain, boolean test) {

this.txBuffer = Collections.synchronizedList(new ArrayList<>());
}

if (!test) {
ees.start(new EpPS());
}
}
}

private Set<Integer> setEvtFilter() {
Set<Integer> eventSN = new HashSet<>();

int sn = IHandler.TYPE.BLOCK0.getValue() << 8;
eventSN.add(sn + EventBlock.CALLBACK.ONBEST0.getValue());

if (poolBackUpEnable) {
sn = IHandler.TYPE.TX0.getValue() << 8;
eventSN.add(sn + EventTx.CALLBACK.TXBACKUP0.getValue());
}

return eventSN;
}

public synchronized RepositoryCache<?> getRepository() {
Expand Down Expand Up @@ -1105,10 +1042,6 @@ public void shutDown() {
if (this.bufferEnable) {
ex.shutdown();
}

if (ees != null) {
ees.shutdown();
}
}

public synchronized void DumpPool() {
Expand Down

0 comments on commit ac7bab1

Please sign in to comment.