コード例 #1
0
ファイル: Blockchain.cs プロジェクト: zpalmtree/cs-turtlecoin
        // Starts the blockchain cache and local storage
        private bool StartBlockchainCache()
        {
            // Initialize database
            switch (Globals.DATABASE_TYPE)
            {
            case DatabaseType.SQLITE:
                DatabaseLocation = CombinePath(Globals.LOCAL_STORAGE_DIRECTORY, Globals.DATABASE_LOCATION);
                Database         = new Sqlite(DatabaseLocation);
                break;

            default:
                throw new ArgumentException("Invalid or non-specified database type");
            }
            Logger.Debug("Database initialized");

            // Start blockchain cache

            /*try
             * {*/
            Blockchain.Start(Database);

            /*}
             * catch (Exception e)
             * {
             *  Logger.Error($"Could not start blockchain cache: {e.Message}");
             *  return false;
             * }
             * Logger.Debug("Cache started");*/

            // Blockchain cache started
            return(true);
        }
コード例 #2
0
ファイル: Node.cs プロジェクト: BrandonT42/CantiLib
        /// <summary>
        /// Starts this node and any associated threads
        /// </summary>
        /// <returns>True if started successfully</returns>
        public bool Start()
        {
            // Start blockchain handler
            Logger.WriteLine("Starting blockchain handler...");
            Logger?.WriteLine($"Database location: {DatabaseLocation}");
            try { Blockchain.Start(Database); }
            catch (Exception e)
            {
                Logger?.Error($"Could not start blockchain handler: {e.Message}");
                return(false);
            }
            Logger?.WriteLine($"Blockchain handler started");

            // Start P2P server
            Logger?.WriteLine("Starting P2P server...");
            if (P2pPort == 0)
            {
                P2pPort = Globals.P2P_DEFAULT_PORT;
            }
            try { P2pServer.Start(P2pPort, Globals.P2P_POLLING_INTERVAL); }
            catch (Exception e)
            {
                Logger?.Error($"Could not start P2P server: {e.Message}");
                return(false);
            }
            Logger?.WriteLine($"P2P server started on port {P2pServer.Port}");

            // Start API server
            Logger?.WriteLine("Starting API server...");
            if (ApiPort == 0)
            {
                ApiPort = Globals.API_DEFAULT_PORT;
            }
            try { ApiServer.Start(ApiPort); }
            catch (Exception e)
            {
                Logger?.Error($"Could not start API server: {e.Message}");
                return(false);
            }
            Logger?.WriteLine($"API server started on port {ApiServer.Port}");

            // Start sync process
            Logger?.WriteLine("Starting sync process...");
            StartSync();

            // Start is completed
            Logger?.Important($"Node initialized with ID {Id}");
            return(true);
        }