| 20 | |
| 21 | |
| 22 | @ReactModule(name = HeliosModule.NAME) |
| 23 | public class HeliosModule extends ReactContextBaseJavaModule { |
| 24 | static { |
| 25 | System.loadLibrary("helios"); |
| 26 | } |
| 27 | |
| 28 | private interface RunnableWithException { |
| 29 | void run() throws Exception; |
| 30 | } |
| 31 | |
| 32 | public static final String NAME = "Helios"; |
| 33 | |
| 34 | private static Map<String, Helios> INSTANCES = new HashMap(); |
| 35 | |
| 36 | private static ExecutorService EXECUTOR = Executors.newFixedThreadPool(1); |
| 37 | |
| 38 | private static final String getKey(final Double pPort) { |
| 39 | return new Integer(pPort.intValue()).toString(); |
| 40 | } |
| 41 | |
| 42 | private static final void shouldStopHelios( |
| 43 | final Double pPort |
| 44 | ) { |
| 45 | final String key = getKey(pPort); |
| 46 | |
| 47 | final Helios maybeHelios = INSTANCES.get(key); |
| 48 | |
| 49 | if (maybeHelios == null) return; |
| 50 | |
| 51 | maybeHelios.heliosShutdown(); |
| 52 | |
| 53 | INSTANCES.remove(key); |
| 54 | } |
| 55 | |
| 56 | private static final void shouldStartHelios( |
| 57 | final String pUntrustedRpcUrl, |
| 58 | final String pConsensusRpcUrl, |
| 59 | final Double pPort, |
| 60 | final String pNetwork, |
| 61 | final String pDataDir, |
| 62 | final String pCheckpoint |
| 63 | ) { |
| 64 | final String key = getKey(pPort); |
| 65 | |
| 66 | final Helios helios = new Helios(); |
| 67 | |
| 68 | helios.heliosStart( |
| 69 | pUntrustedRpcUrl, |
| 70 | pConsensusRpcUrl, |
| 71 | pPort, |
| 72 | pNetwork, |
| 73 | pDataDir, |
| 74 | pCheckpoint |
| 75 | ); |
| 76 | |
| 77 | INSTANCES.put(key, helios); |
| 78 | } |
| 79 |
nothing calls this directly
no outgoing calls
no test coverage detected