use of org.aion.equihash.Solution 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