static public void stop() { Program.noStart = true; forceShutdown = true; ConsoleHelpers.forceShutdown = true; // Stop the keepalive thread PresenceList.stopKeepAlive(); // Stop the block processor blockProcessor.stopOperation(); // Stop the block sync blockSync.stop(); // Stop the API server if (apiServer != null) { apiServer.stop(); apiServer = null; } // Stop the miner if (miner != null) { miner.stop(); miner = null; } if (maintenanceThread != null) { maintenanceThread.Abort(); maintenanceThread = null; } // Stop the block storage Storage.stopStorage(); // stop activity storage ActivityStorage.stopStorage(); // Stop the network queue NetworkQueue.stop(); // Stop all network clients NetworkClientManager.stop(); // Stop the network server NetworkServer.stopNetworkOperations(); // Stop the console stats screen // Console screen has a thread running even if we are in verbose mode statsConsoleScreen.stop(); NetDump.Instance.shutdown(); presenceListActive = false; }
// Cleans the storage cache and logs public static bool cleanCacheAndLogs() { ActivityStorage.deleteCache(); PeerStorage.deletePeersFile(); Logging.clear(); Logging.info("Cleaned cache and logs."); return(true); }
static public void stop() { Program.noStart = true; forceShutdown = true; ConsoleHelpers.forceShutdown = true; // Stop the keepalive thread PresenceList.stopKeepAlive(); // Stop the API server if (apiServer != null) { apiServer.stop(); apiServer = null; } if (maintenanceThread != null) { maintenanceThread.Abort(); maintenanceThread = null; } ActivityStorage.stopStorage(); // Stop the network queue NetworkQueue.stop(); // Check for test client mode if (Config.isTestClient) { TestClientNode.stop(); return; } // Stop all network clients NetworkClientManager.stop(); // Stop the network server NetworkServer.stopNetworkOperations(); // Stop the console stats screen // Console screen has a thread running even if we are in verbose mode statsConsoleScreen.stop(); }
static public void start(bool verboseConsoleOutput) { // Network configuration NetworkUtils.configureNetwork(); PresenceList.generatePresenceList(Config.publicServerIP, 'R'); // Start the network queue NetworkQueue.start(); ActivityStorage.prepareStorage(); // Start the HTTP JSON API server apiServer = new APIServer(); // Prepare stats screen Config.verboseConsoleOutput = verboseConsoleOutput; Logging.consoleOutput = verboseConsoleOutput; Logging.flush(); if (Config.verboseConsoleOutput == false) { statsConsoleScreen.clearScreen(); } // Check for test client mode if (Config.isTestClient) { TestClientNode.start(); return; } // Start the node stream server NetworkServer.beginNetworkOperations(); // Start the network client manager NetworkClientManager.start(); // Start the keepalive thread PresenceList.startKeepAlive(); // Start the maintenance thread maintenanceThread = new Thread(performMaintenance); maintenanceThread.Start(); }
// Cleans the storage cache and logs public static bool cleanCacheAndLogs() { ActivityStorage.deleteCache(); // deleting block storage is a special case // we have to instantiate whatever implementation we are using and remove its data files /*storage = IStorage.create(Config.blockStorageProvider); * storage.deleteData();*/ Storage.deleteCache(); WalletStateStorage.deleteCache(); PeerStorage.deletePeersFile(); Logging.clear(); Logging.info("Cleaned cache and logs."); return(true); }
// Start the node public void start(bool verboseConsoleOutput) { char node_type = 'M'; // TODO TODO TODO TODO change this to 'W' or 'C' after the upgrade if (Config.disableMiner) { node_type = 'M'; } // Check if we're in worker-only mode if (Config.workerOnly) { // Enable miner Config.disableMiner = false; node_type = 'W'; CoreConfig.simultaneousConnectedNeighbors = 4; } // Generate presence list PresenceList.init(IxianHandler.publicIP, Config.serverPort, node_type); // Initialize storage Storage.prepareStorage(); ActivityStorage.prepareStorage(); // Initialize the block chain blockChain = new BlockChain(); //runDiffTests(); //return; // Create the block processor and sync blockProcessor = new BlockProcessor(); blockSync = new BlockSync(); if (Config.devInsertFromJson) { Console.WriteLine("Inserting from JSON"); devInsertFromJson(); Program.noStart = true; return; } if (Config.apiBinds.Count == 0) { Config.apiBinds.Add("http://localhost:" + Config.apiPort + "/"); } // Start the HTTP JSON API server apiServer = new APIServer(Config.apiBinds, Config.apiUsers, Config.apiAllowedIps); if (IXICore.Platform.onMono() == false && !Config.disableWebStart) { System.Diagnostics.Process.Start(Config.apiBinds[0]); } miner = new Miner(); // Start the network queue NetworkQueue.start(); // prepare stats screen ConsoleHelpers.verboseConsoleOutput = verboseConsoleOutput; Logging.consoleOutput = verboseConsoleOutput; Logging.flush(); if (ConsoleHelpers.verboseConsoleOutput == false) { statsConsoleScreen.clearScreen(); } // Distribute genesis funds IxiNumber genesisFunds = new IxiNumber(Config.genesisFunds); // Check if this is a genesis node if (genesisFunds > (long)0) { Logging.info(String.Format("Genesis {0} specified. Starting operation.", genesisFunds)); distributeGenesisFunds(genesisFunds); genesisNode = true; blockProcessor.resumeOperation(); serverStarted = true; if (!isMasterNode()) { Logging.info("Network server is not enabled in modes other than master node."); } else { NetworkServer.beginNetworkOperations(); } } else { if (File.Exists(Config.genesisFile)) { Block genesis = new Block(Crypto.stringToHash(File.ReadAllText(Config.genesisFile))); blockChain.setGenesisBlock(genesis); } ulong lastLocalBlockNum = Meta.Storage.getLastBlockNum(); if (lastLocalBlockNum > 6) { lastLocalBlockNum = lastLocalBlockNum - 6; } if (Config.lastGoodBlock > 0 && Config.lastGoodBlock < lastLocalBlockNum) { lastLocalBlockNum = Config.lastGoodBlock; } if (lastLocalBlockNum > 0) { Block b = blockChain.getBlock(lastLocalBlockNum, true); if (b != null) { ConsensusConfig.minRedactedWindowSize = ConsensusConfig.getRedactedWindowSize(b.version); ConsensusConfig.redactedWindowSize = ConsensusConfig.getRedactedWindowSize(b.version); } } if (Config.recoverFromFile) { Block b = Meta.Storage.getBlock(lastLocalBlockNum); blockSync.onHelloDataReceived(b.blockNum, b.blockChecksum, b.version, b.walletStateChecksum, b.getSignatureCount(), lastLocalBlockNum); } else { ulong blockNum = WalletStateStorage.restoreWalletState(lastLocalBlockNum); if (blockNum > 0) { Block b = blockChain.getBlock(blockNum, true); if (b != null) { blockSync.onHelloDataReceived(blockNum, b.blockChecksum, b.version, b.walletStateChecksum, b.getSignatureCount(), lastLocalBlockNum); } else { walletState.clear(); } } else { blockSync.lastBlockToReadFromStorage = lastLocalBlockNum; } // Start the server for ping purposes serverStarted = true; if (!isMasterNode()) { Logging.info("Network server is not enabled in modes other than master node."); } else { NetworkServer.beginNetworkOperations(); } // Start the network client manager NetworkClientManager.start(); } } PresenceList.startKeepAlive(); TLC = new ThreadLiveCheck(); // Start the maintenance thread maintenanceThread = new Thread(performMaintenance); maintenanceThread.Name = "Node_Maintenance_Thread"; maintenanceThread.Start(); }