Search in sources :

Example 16 with NetConfig

use of com.icodici.universa.node2.NetConfig in project universa by UniversaBlockchain.

the class Main method startClientHttpServer.

private void startClientHttpServer() throws Exception {
    log("prepare to start client HTTP server on " + myInfo.getClientAddress().getPort());
    clientHTTPServer = new ClientHTTPServer(nodeKey, myInfo.getClientAddress().getPort(), logger);
    clientHTTPServer.setCache(cache);
    clientHTTPServer.setParcelCache(parcelCache);
    clientHTTPServer.setNetConfig(netConfig);
// node = new Node()
}
Also used : ClientHTTPServer(com.icodici.universa.node2.network.ClientHTTPServer)

Example 17 with NetConfig

use of com.icodici.universa.node2.NetConfig in project universa by UniversaBlockchain.

the class Main method startNode.

private void startNode() throws SQLException, IOException {
    config.setConsensusConfigUpdater((config, n) -> {
        // Until we fix the announcer
        int negative = (int) Math.ceil(n * 0.11);
        if (negative < 1)
            negative = 1;
        int positive = (int) Math.floor(n * 0.90);
        if (negative + positive == n)
            negative += 1;
        int resyncBreak = (int) Math.ceil(n * 0.2);
        if (resyncBreak < 1)
            resyncBreak = 1;
        if (resyncBreak + positive == n)
            resyncBreak += 1;
        log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak);
        config.setPositiveConsensus(positive);
        config.setNegativeConsensus(negative);
        config.setResyncBreakConsensus(resyncBreak);
    });
    network = new NetworkV2(netConfig, myInfo, nodeKey);
    node = new Node(config, myInfo, ledger, network);
    cache = node.getCache();
    parcelCache = node.getParcelCache();
    StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A=="));
    if (r != null)
        r.destroy();
    clientHTTPServer.setConfig(config);
    clientHTTPServer.setNode(node);
    clientHTTPServer.setCache(cache);
    clientHTTPServer.setParcelCache(parcelCache);
    clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost"));
}
Also used : StateRecord(com.icodici.universa.node.StateRecord) NetworkV2(com.icodici.universa.node2.network.NetworkV2)

Aggregations

NodeInfo (com.icodici.universa.node2.NodeInfo)15 NetConfig (com.icodici.universa.node2.NetConfig)14 SymmetricKey (com.icodici.crypto.SymmetricKey)13 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)11 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)9 Random (java.util.Random)5 TimeoutException (java.util.concurrent.TimeoutException)5 AsyncEvent (net.sergeych.tools.AsyncEvent)5 Arrays.asList (java.util.Arrays.asList)4 List (java.util.List)4 PooledDb (com.icodici.db.PooledDb)2 SQLException (java.sql.SQLException)2 PrivateKey (com.icodici.crypto.PrivateKey)1 StateRecord (com.icodici.universa.node.StateRecord)1 ClientHTTPServer (com.icodici.universa.node2.network.ClientHTTPServer)1 NetworkV2 (com.icodici.universa.node2.network.NetworkV2)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1