Search in sources :

Example 1 with API

use of com.iota.iri.service.API in project iri by iotaledger.

the class NodeIntegrationTests method testGetsSolid.

// @Test
public void testGetsSolid() throws Exception {
    int count = 1;
    long spacing = 5000;
    Iota[] iotaNodes = new Iota[count];
    API[] api = new API[count];
    IXI[] ixi = new IXI[count];
    Thread cooThread, master;
    TemporaryFolder[] folders = new TemporaryFolder[count * 2];
    for (int i = 0; i < count; i++) {
        folders[i * 2] = new TemporaryFolder();
        folders[i * 2 + 1] = new TemporaryFolder();
        iotaNodes[i] = newNode(i, folders[i * 2], folders[i * 2 + 1]);
        ixi[i] = new IXI(iotaNodes[i]);
        ixi[i].init(iotaNodes[i].configuration.string(Configuration.DefaultConfSettings.IXI_DIR));
        api[i] = new API(iotaNodes[i], ixi[i]);
        api[i].init();
    }
    Node.uri("udp://localhost:14701").ifPresent(uri -> iotaNodes[0].node.addNeighbor(iotaNodes[0].node.newNeighbor(uri, true)));
    // Node.uri("udp://localhost:14700").ifPresent(uri -> iotaNodes[1].node.addNeighbor(iotaNodes[1].node.newNeighbor(uri, true)));
    cooThread = new Thread(spawnCoordinator(api[0], spacing), "Coordinator");
    master = new Thread(spawnMaster(), "master");
    /*
        TODO: Put some test stuff here
         */
    cooThread.start();
    master.start();
    synchronized (waitObj) {
        waitObj.wait();
    }
    for (int i = 0; i < count; i++) {
        ixi[i].shutdown();
        api[i].shutDown();
        iotaNodes[i].shutdown();
    }
    for (TemporaryFolder folder : folders) {
        folder.delete();
    }
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) API(com.iota.iri.service.API)

Example 2 with API

use of com.iota.iri.service.API in project iri by iotaledger.

the class IRI method main.

public static void main(final String[] args) throws IOException {
    configuration = new Configuration();
    validateParams(configuration, args);
    log.info("Welcome to {} {}", configuration.booling(DefaultConfSettings.TESTNET) ? TESTNET_NAME : MAINNET_NAME, VERSION);
    iota = new Iota(configuration);
    ixi = new IXI(iota);
    api = new API(iota, ixi);
    shutdownHook();
    if (configuration.booling(DefaultConfSettings.DEBUG)) {
        log.info("You have set the debug flag. To enable debug output, you need to uncomment the DEBUG appender in the source tree at iri/src/main/resources/logback.xml and re-package iri.jar");
    }
    if (configuration.booling(DefaultConfSettings.EXPORT)) {
        File exportDir = new File("export");
        // if the directory does not exist, create it
        if (!exportDir.exists()) {
            log.info("Create directory 'export'");
            try {
                exportDir.mkdir();
            } catch (SecurityException e) {
                log.error("Could not create directory", e);
            }
        }
        exportDir = new File("export-solid");
        // if the directory does not exist, create it
        if (!exportDir.exists()) {
            log.info("Create directory 'export-solid'");
            try {
                exportDir.mkdir();
            } catch (SecurityException e) {
                log.error("Could not create directory", e);
            }
        }
    }
    try {
        iota.init();
        api.init();
        ixi.init(configuration.string(Configuration.DefaultConfSettings.IXI_DIR));
    } catch (final Exception e) {
        log.error("Exception during IOTA node initialisation: ", e);
        System.exit(-1);
    }
    log.info("IOTA Node initialised correctly.");
}
Also used : Configuration(com.iota.iri.conf.Configuration) API(com.iota.iri.service.API) File(java.io.File) IOException(java.io.IOException)

Aggregations

API (com.iota.iri.service.API)2 Configuration (com.iota.iri.conf.Configuration)1 File (java.io.File)1 IOException (java.io.IOException)1 TemporaryFolder (org.junit.rules.TemporaryFolder)1