Example #1
0
        public Node()
        {
#if DEBUG
            Logging.warn("Testing language files");
            SpixiLocalization.testLanguageFiles("en-us");
#endif

            Logging.info("Initing node constructor");

            Instance = this;

            IxianHandler.init(Config.version, this, Config.networkType);

            // Prepare the wallet
            walletStorage = new WalletStorage(Path.Combine(Config.spixiUserFolder, Config.walletFile));

            PeerStorage.init(Config.spixiUserFolder);

            // Init TIV
            tiv = new TransactionInclusion();

            Logging.info("Initing local storage");

            // Prepare the local storage
            localStorage = new SPIXI.Storage.LocalStorage(Config.spixiUserFolder);

            customAppManager = new CustomAppManager(Config.spixiUserFolder);

            FriendList.init(Config.spixiUserFolder);

            Logging.info("Node init done");
        }
Example #2
0
        // Perform basic initialization of node
        private void init()
        {
            Logging.consoleOutput = false;

            CoreConfig.isTestNet = false;

            running = true;

            // Load or Generate the wallet
            if (!initWallet())
            {
                running = false;
                IxianLiteWallet.Program.noStart = true;
                return;
            }

            Console.WriteLine("Connecting to Ixian network...");

            string headers_path = "";

            if (!CoreConfig.isTestNet)
            {
                headers_path = "headers";
            }
            else
            {
                headers_path = "testnet-headers";
                PeerStorage.init("", "testner-peers.ixi");
            }

            // Init TIV
            tiv = new TransactionInclusion(headers_path);
        }
Example #3
0
        // Perform basic initialization of node
        private void init()
        {
            running = true;

            CoreConfig.maximumServerMasterNodes = Config.maximumStreamClients;
            CoreConfig.maximumServerClients     = Config.maximumStreamClients;

            UpdateVerify.init(Config.checkVersionUrl, Config.checkVersionSeconds);

            // Network configuration
            NetworkUtils.configureNetwork(Config.externalIp, Config.serverPort);

            // Load or Generate the wallet
            if (!initWallet())
            {
                running            = false;
                S2.Program.noStart = true;
                return;
            }

            // Setup the stats console
            statsConsoleScreen = new StatsConsoleScreen();

            PeerStorage.init("");

            // Init TIV
            tiv = new TransactionInclusion();
        }
Example #4
0
        public Node()
        {
            Instance = this;

            CoreConfig.productVersion = Config.version;
            IxianHandler.setHandler(this);

            CoreConfig.isTestNet = Config.isTestNet;

            // Initialize the crypto manager
            CryptoManager.initLib();

            // Prepare the wallet
            walletStorage = new WalletStorage(Path.Combine(Config.spixiUserFolder, Config.walletFile));

            string peers_filename = "peers.ixi";

            if (CoreConfig.isTestNet)
            {
                peers_filename = "testnet-peers.ixi";
            }

            PeerStorage.init(Config.spixiUserFolder, peers_filename);

            ulong block_height = 1;

            byte[] block_checksum = null;

            if (!walletStorage.walletExists())
            {
                block_height   = Config.bakedBlockHeight;
                block_checksum = Config.bakedBlockChecksum;
            }

            string headers_path = "";

            if (!Config.isTestNet)
            {
                headers_path = Path.Combine(Config.spixiUserFolder, "headers");
            }
            else
            {
                // Temporary hack for our beta testers, remove before release
                string tmp_path = Path.Combine(Config.spixiUserFolder, "headers");
                BlockHeaderStorage.init(tmp_path);
                BlockHeaderStorage.deleteCache();
                BlockHeaderStorage.stop();
                // End of hack

                headers_path = Path.Combine(Config.spixiUserFolder, "testnet-headers");
            }
            // Init TIV
            tiv = new TransactionInclusion(headers_path, block_height, block_checksum);

            // Prepare the local storage
            localStorage = new SPIXI.Storage.LocalStorage(Config.spixiUserFolder);

            customAppManager = new CustomAppManager(Config.spixiUserFolder);
        }
Example #5
0
        public Node()
        {
            Instance = this;

            CoreConfig.productVersion = Config.version;
            IxianHandler.setHandler(this);

            CoreConfig.isTestNet = Config.isTestNet;

            // Prepare the wallet
            walletStorage = new WalletStorage(Path.Combine(Config.spixiUserFolder, Config.walletFile));

            string peers_filename = "peers.ixi";

            if (CoreConfig.isTestNet)
            {
                peers_filename = "testnet-peers.ixi";
            }

            PeerStorage.init(Config.spixiUserFolder, peers_filename);

            ulong block_height = 1;

            byte[] block_checksum = null;

            string headers_path;

            if (Config.isTestNet)
            {
                headers_path = Path.Combine(Config.spixiUserFolder, "testnet-headers");
            }
            else
            {
                headers_path = Path.Combine(Config.spixiUserFolder, "headers");
                if (!walletStorage.walletExists())
                {
                    block_height   = Config.bakedBlockHeight;
                    block_checksum = Config.bakedBlockChecksum;
                }
                else
                {
                    block_height   = Config.bakedRecoveryBlockHeight;
                    block_checksum = Config.bakedRecoveryBlockChecksum;
                }
            }
            // Init TIV
            tiv = new TransactionInclusion(headers_path, block_height, block_checksum);

            // Prepare the local storage
            localStorage = new SPIXI.Storage.LocalStorage(Config.spixiUserFolder);

            customAppManager = new CustomAppManager(Config.spixiUserFolder);
        }
Example #6
0
        // Perform basic initialization of node
        public void init()
        {
            running = true;

            // First create the data folder if it does not already exist
            checkDataFolder();

            renameStorageFiles(); // this function will be here temporarily for the next few version, then it will be removed to keep a cleaner code base

            // debug
            if (Config.networkDumpFile != "")
            {
                NetDump.Instance.start(Config.networkDumpFile);
            }

            UpdateVerify.init(Config.checkVersionUrl, Config.checkVersionSeconds);

            // Initialize storage
            if (storage is null)
            {
                storage = IStorage.create(Config.blockStorageProvider);
            }
            if (!storage.prepareStorage())
            {
                Logging.error("Error while preparing block storage! Aborting.");
                Program.noStart = true;
                return;
            }

            NetworkUtils.configureNetwork(Config.externalIp, Config.serverPort);

            // Load or Generate the wallet
            if (!initWallet())
            {
                storage.stopStorage();
                running = false;
                DLTNode.Program.noStart = true;
                return;
            }

            // Setup the stats console
            statsConsoleScreen = new StatsConsoleScreen();

            // Initialize the wallet state
            walletState = new WalletState();

            inventoryCache = new InventoryCacheDLT();

            PeerStorage.init("");
        }
Example #7
0
        // Perform basic initialization of node
        private void init()
        {
            running = true;

            CoreConfig.maximumServerMasterNodes = Config.maximumStreamClients;
            CoreConfig.maximumServerClients     = Config.maximumStreamClients;

            UpdateVerify.init(Config.checkVersionUrl, Config.checkVersionSeconds);

            // Network configuration
            NetworkUtils.configureNetwork(Config.externalIp, Config.serverPort);

            // Load or Generate the wallet
            if (!initWallet())
            {
                running = false;
                SpixiBot.Program.noStart = true;
                return;
            }

            // Setup the stats console
            statsConsoleScreen = new StatsConsoleScreen();

            PeerStorage.init("");

            // Init TIV
            tiv = new TransactionInclusion();

            string avatarPath = Path.Combine(Config.dataDirectory, "Avatars");

            users = new BotUsers(Path.Combine(Config.dataDirectory, "contacts.dat"), avatarPath, false);
            users.loadContactsFromFile();

            groups = new BotGroups(Path.Combine(Config.dataDirectory, "groups.dat"));
            groups.loadGroupsFromFile();

            channels = new BotChannels(Path.Combine(Config.dataDirectory, "channels.dat"));
            channels.loadChannelsFromFile();

            StreamProcessor.init(Path.Combine(Config.dataDirectory, "Messages"));
        }
Example #8
0
        // Perform basic initialization of node
        private void init()
        {
            Logging.consoleOutput = false;

            running = true;

            // Load or Generate the wallet
            if (!initWallet())
            {
                running = false;
                IxianLiteWallet.Program.running = false;
                return;
            }

            Console.WriteLine("Connecting to Ixian network...");

            PeerStorage.init("");

            // Init TIV
            tiv = new TransactionInclusion();
        }
Example #9
0
        public Node()
        {
            CoreConfig.productVersion = Config.version;
            IxianHandler.setHandler(this);

            CoreConfig.isTestNet = Config.isTestNet;

            // Initialize the crypto manager
            CryptoManager.initLib();

            // Prepare the wallet
            walletStorage = new WalletStorage(Path.Combine(Config.spixiUserFolder, Config.walletFile));

            string peers_filename = "peers.ixi";

            if (CoreConfig.isTestNet)
            {
                peers_filename = "testnet-peers.ixi";
            }

            PeerStorage.init(Config.spixiUserFolder, peers_filename);
        }
Example #10
0
        public Node()
        {
#if DEBUG
            Logging.warn("Testing language files");
            Lang.SpixiLocalization.testLanguageFiles("en-us");
#endif


            Logging.info("Initing node constructor");

            Instance = this;

            CoreConfig.simultaneousConnectedNeighbors = 6;

            IxianHandler.init(Config.version, this, Config.networkType);

            PeerStorage.init(Config.spixiUserFolder);

            // Init TIV
            tiv = new TransactionInclusion();

            Logging.info("Initing local storage");

            // Prepare the local storage
            localStorage = new SPIXI.Storage.LocalStorage(Config.spixiUserFolder);

            customAppManager = new CustomAppManager(Config.spixiUserFolder);

            FriendList.init(Config.spixiUserFolder);

            Logging.info("Node init done");

            string backup_file_name = Path.Combine(Config.spixiUserFolder, "spixi.account.backup.ixi");
            if (File.Exists(backup_file_name))
            {
                File.Delete(backup_file_name);
            }
        }
Example #11
0
            public static void readFromCommandLine(string[] args)
            {
                // first pass
                var cmd_parser = new FluentCommandLineParser();

                // help
                cmd_parser.SetupHelp("h", "help").Callback(text => outputHelp());

                // config file
                cmd_parser.Setup <string>("config").Callback(value => configFilename = value).Required();

                cmd_parser.Parse(args);

                if (DLTNode.Program.noStart)
                {
                    return;
                }

                readConfigFile(configFilename);



                // second pass
                cmd_parser = new FluentCommandLineParser();

                // Block storage provider
                cmd_parser.Setup <string>("blockStorage").Callback(value => blockStorageProvider = value).Required();

                // testnet
                cmd_parser.Setup <bool>('t', "testnet").Callback(value => CoreConfig.isTestNet = true).Required();

                cmd_parser.Parse(args);

                if (CoreConfig.isTestNet)
                {
                    Config.serverPort = defaultTestnetServerPort;
                    apiPort           = testnetApiPort;
                    dataFolderPath    = "data-testnet";
                    PeerStorage.init(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "testnet-peers.dat");
                    genesisFile = "testnet-genesis.dat";
                }
                else
                {
                    Config.serverPort = defaultServerPort;
                    PeerStorage.init(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
                }



                string seedNode = "";

                // third pass
                cmd_parser = new FluentCommandLineParser();

                int start_clean = 0; // Flag to determine if node should delete cache+logs

                // version
                cmd_parser.Setup <bool>('v', "version").Callback(text => outputVersion());

                // Toggle between full history node and no history
                cmd_parser.Setup <bool>('s', "save-history").Callback(value => storeFullHistory = value).Required();

                // Toggle worker-only mode
                cmd_parser.Setup <bool>("worker").Callback(value => workerOnly = true).Required();

                // Check for password change
                cmd_parser.Setup <bool>('x', "changepass").Callback(value => changePass = value).Required();

                // Check for recovery parameter
                cmd_parser.Setup <bool>("recover").Callback(value => recoverFromFile = value).Required();

                // Check for clean parameter
                cmd_parser.Setup <bool>('c', "clean").Callback(value => start_clean = 1);
                cmd_parser.Setup <bool>('f', "force").Callback(value => { if (start_clean > 0)
                                                                          {
                                                                              start_clean += 1;
                                                                          }
                                                               });


                cmd_parser.Setup <int>('p', "port").Callback(value => Config.serverPort = value).Required();

                cmd_parser.Setup <int>('a', "apiport").Callback(value => apiPort = value).Required();

                cmd_parser.Setup <string>('i', "ip").Callback(value => externalIp = value).Required();

                cmd_parser.Setup <string>("genesis").Callback(value => genesisFunds = value).Required();

                cmd_parser.Setup <string>("genesis2").Callback(value => genesis2Address = value).Required();

                cmd_parser.Setup <int>("threads").Callback(value => miningThreads = (uint)value).Required();

                cmd_parser.Setup <string>('w', "wallet").Callback(value => walletFile = value).Required();

                cmd_parser.Setup <string>('n', "node").Callback(value => seedNode = value).Required();

                cmd_parser.Setup <int>("maxLogSize").Callback(value => maxLogSize = value).Required();

                cmd_parser.Setup <int>("maxLogCount").Callback(value => maxLogCount = value).Required();

                cmd_parser.Setup <long>("lastGoodBlock").Callback(value => lastGoodBlock = (ulong)value).Required();

                cmd_parser.Setup <bool>("disableWebStart").Callback(value => disableWebStart = true).Required();

                cmd_parser.Setup <string>("dataFolderPath").Callback(value => dataFolderPath = value).Required();

                cmd_parser.Setup <bool>("optimizeDBStorage").Callback(value => optimizeDBStorage = value).Required();

                cmd_parser.Setup <bool>("verifyStorage").Callback(value => fullStorageDataVerification = true).Required();

                cmd_parser.Setup <bool>("onlyShowAddresses").Callback(value => onlyShowAddresses = true).Required();


                // Debug
                cmd_parser.Setup <string>("netdump").Callback(value => networkDumpFile = value).SetDefault("");

                cmd_parser.Setup <int>("benchmarkKeys").Callback(value => benchmarkKeys = value).SetDefault(0);

                cmd_parser.Setup <bool>("generateWallet").Callback(value => generateWalletOnly = value).SetDefault(false);

                cmd_parser.Setup <string>("walletPassword").Callback(value => dangerCommandlinePasswordCleartextUnsafe = value).SetDefault("");

                cmd_parser.Setup <bool>("noNetworkSync").Callback(value => noNetworkSync = true).Required();

                cmd_parser.Setup <bool>("devInsertFromJson").Callback(value => devInsertFromJson = true).Required();

                cmd_parser.Setup <bool>("offline").Callback(value => CoreConfig.preventNetworkOperations = true).Required();

                cmd_parser.Parse(args);

                WalletStateStorage.path = dataFolderPath + Path.DirectorySeparatorChar + "ws";

                if (start_clean > 0)
                {
                    bool do_clean = false;
                    if (start_clean > 1)
                    {
                        Logging.warn("Ixian DLT node started with the forced clean parameter (-c -c).");
                        do_clean = true;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("You have started the Ixian DLT node with the '-c' parameter, indicating that you wish to clear all cache and log files.");
                        Console.Write("This will cause the node to re-download any neccessary data, which may take some time. Are you sure? (Y/N)");
                        Console.ResetColor();
                        var k = Console.ReadKey();
                        if (k.Key == ConsoleKey.Y)
                        {
                            do_clean = true;
                        }
                    }
                    if (do_clean)
                    {
                        Node.checkDataFolder();
                        Node.cleanCacheAndLogs();
                    }
                    else
                    {
                        DLTNode.Program.noStart = true;
                        return;
                    }
                }

                if (miningThreads < 1)
                {
                    miningThreads = 1;
                }

                if (seedNode != "")
                {
                    if (CoreConfig.isTestNet)
                    {
                        CoreNetworkUtils.seedTestNetNodes = new List <string[]>
                        {
                            new string[2] {
                                seedNode, null
                            }
                        };
                    }
                    else
                    {
                        CoreNetworkUtils.seedNodes = new List <string[]>
                        {
                            new string[2] {
                                seedNode, null
                            }
                        };
                    }
                }
            }
Example #12
0
        public static void readFromCommandLine(string[] args)
        {
            // first pass
            var cmd_parser = new FluentCommandLineParser();

            // help
            cmd_parser.SetupHelp("h", "help").Callback(text => outputHelp());

            // config file
            cmd_parser.Setup <string>("config").Callback(value => configFilename = value).Required();

            cmd_parser.Parse(args);

            if (S2.Program.noStart)
            {
                return;
            }

            readConfigFile(configFilename);



            // second pass
            cmd_parser = new FluentCommandLineParser();

            // testnet
            cmd_parser.Setup <bool>('t', "testnet").Callback(value => CoreConfig.isTestNet = true).Required();

            cmd_parser.Parse(args);

            if (CoreConfig.isTestNet)
            {
                Config.serverPort = defaultTestnetServerPort;
                apiPort           = testnetApiPort;
                PeerStorage.init(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "testnet-peers.dat");
            }
            else
            {
                Config.serverPort = defaultServerPort;
                PeerStorage.init(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
            }



            string seedNode = "";

            // third pass
            cmd_parser = new FluentCommandLineParser();

            bool start_clean = false; // Flag to determine if node should delete cache+logs

            // version
            cmd_parser.Setup <bool>('v', "version").Callback(text => outputVersion());

            // Check for password change
            cmd_parser.Setup <bool>('x', "changepass").Callback(value => changePass = value).Required();

            // Check for clean parameter
            cmd_parser.Setup <bool>('c', "clean").Callback(value => start_clean = value).Required();


            cmd_parser.Setup <int>('p', "port").Callback(value => Config.serverPort = value).Required();

            cmd_parser.Setup <int>('a', "apiport").Callback(value => apiPort = value).Required();

            cmd_parser.Setup <string>('i', "ip").Callback(value => externalIp = value).Required();

            cmd_parser.Setup <string>('w', "wallet").Callback(value => walletFile = value).Required();

            cmd_parser.Setup <string>('n', "node").Callback(value => seedNode = value).Required();

            cmd_parser.Setup <int>("maxLogSize").Callback(value => maxLogSize = value).Required();

            cmd_parser.Setup <int>("maxLogCount").Callback(value => maxLogCount = value).Required();

            cmd_parser.Setup <bool>("disableWebStart").Callback(value => disableWebStart = true).Required();

            cmd_parser.Setup <bool>("onlyShowAddresses").Callback(value => onlyShowAddresses = true).Required();


            // Debug
            cmd_parser.Setup <string>("netdump").Callback(value => networkDumpFile = value).SetDefault("");

            cmd_parser.Setup <int>("forceTimeOffset").Callback(value => CoreConfig.forceTimeOffset = value).Required();

            cmd_parser.Setup <bool>("generateWallet").Callback(value => generateWalletOnly = value).SetDefault(false);

            cmd_parser.Setup <string>("walletPassword").Callback(value => dangerCommandlinePasswordCleartextUnsafe = value).SetDefault("");

            cmd_parser.Setup <bool>("testClient").Callback(value => isTestClient = true).Required();

            cmd_parser.Parse(args);


            // Validate parameters

            if (start_clean)
            {
                Node.cleanCacheAndLogs();
            }

            if (seedNode != "")
            {
                if (CoreConfig.isTestNet)
                {
                    CoreNetworkUtils.seedTestNetNodes = new List <string[]>
                    {
                        new string[2] {
                            seedNode, null
                        }
                    };
                }
                else
                {
                    CoreNetworkUtils.seedNodes = new List <string[]>
                    {
                        new string[2] {
                            seedNode, null
                        }
                    };
                }
            }
        }