use of org.aion.evtmgr.impl.evt.EventConsensus in project aion by aionnetwork.
the class SyncMgr method setupEventHandler.
private void setupEventHandler() {
List<IEvent> events = new ArrayList<>();
events.add(new EventConsensus(EventConsensus.CALLBACK.ON_SYNC_DONE));
this.evtMgr.registerEvent(events);
}
use of org.aion.evtmgr.impl.evt.EventConsensus in project aion by aionnetwork.
the class AbstractHandlerTest method testRemoveEvent.
@Test
public void testRemoveEvent() {
AbstractHandler handler = new BlockHandler();
handler.addEvent(new EventConsensus(EventConsensus.CALLBACK.ON_BLOCK_TEMPLATE));
boolean res = handler.removeEvent(new EventBlock(EventBlock.CALLBACK.ONTRACE0));
assertFalse(res);
boolean res2 = handler.removeEvent(null);
assertFalse(res2);
boolean res3 = handler.removeEvent(new EventConsensus(EventConsensus.CALLBACK.ON_BLOCK_TEMPLATE));
assertTrue(res3);
}
use of org.aion.evtmgr.impl.evt.EventConsensus in project aion by aionnetwork.
the class EventExecuteServiceTest method testEES.
@Test
public void testEES() {
eventExecuteService.setFilter(getFilter());
eventExecuteService.add(new EventDummy());
eventExecuteService.add(new EventTx(EventTx.CALLBACK.PENDINGTXSTATECHANGE0));
eventExecuteService.add(new EventBlock(EventBlock.CALLBACK.ONBLOCK0));
eventExecuteService.add(new EventMiner(EventMiner.CALLBACK.MININGSTARTED));
eventExecuteService.add(new EventConsensus(EventConsensus.CALLBACK.ON_SYNC_DONE));
eventExecuteService.take();
eventExecuteService.take();
eventExecuteService.take();
eventExecuteService.take();
eventExecuteService.take();
}
use of org.aion.evtmgr.impl.evt.EventConsensus in project aion by aionnetwork.
the class AbstractEventTest method testHashCode.
@Test
public void testHashCode() {
EventBlock eventBlock1 = new EventBlock(EventBlock.CALLBACK.ONBLOCK0);
EventBlock eventBlock2 = new EventBlock(EventBlock.CALLBACK.ONBEST0);
EventConsensus eventConsensus1 = new EventConsensus(EventConsensus.CALLBACK.ON_SYNC_DONE);
EventConsensus eventConsensus2 = new EventConsensus(EventConsensus.CALLBACK.ON_BLOCK_TEMPLATE);
// check the hash codes
System.out.println(eventBlock1.hashCode());
System.out.println(eventBlock2.hashCode());
System.out.println(eventConsensus1.hashCode());
System.out.println(eventConsensus2.hashCode());
}
use of org.aion.evtmgr.impl.evt.EventConsensus in project aion by aionnetwork.
the class ApiWeb3Aion method stratum_submitblock.
public Object stratum_submitblock(Object nce, Object soln, Object hdrHash, Object ts) {
JSONObject obj = new JSONObject();
if (nce != null && soln != null && hdrHash != null && ts != null && !nce.equals(null) && !soln.equals(null) && !hdrHash.equals(null) && !ts.equals(null)) {
templateMapLock.writeLock().lock();
AionBlock bestBlock = templateMap.get(hdrHash + "");
if (bestBlock != null) {
IEvent ev = new EventConsensus(EventConsensus.CALLBACK.ON_SOLUTION);
ev.setFuncArgs(Collections.singletonList(new Solution(bestBlock, hexStringToBytes(nce + ""), hexStringToBytes(soln + ""), Long.parseLong(ts + "", 16))));
evtMgr.newEvent(ev);
LOG.info("block submitted via api <num={}, hash={}, diff={}, tx={}>", bestBlock.getNumber(), // LogUtil.toHexF8(newBlock.getHash()),
bestBlock.getShortHash(), bestBlock.getHeader().getDifficultyBI().toString(), bestBlock.getTransactionsList().size());
templateMap.clear();
}
templateMapLock.writeLock().unlock();
// TODO: Simplified response for now, need to provide better feedback to caller in next update
obj.put("result", true);
} else {
obj.put("message", "success");
obj.put("code", -1);
}
return obj;
}
Aggregations