Example #1
0
        void InitalizeCkbIfNecessary()
        {
            if (File.Exists(TomlFile))
            {
                return;
            }

            using System.Diagnostics.Process process = new();
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardInput  = true;

            process.StartInfo.FileName         = BinaryFullPath(WorkPathManage.CkbForPaltform(ckbenum.ckb));
            process.StartInfo.WorkingDirectory = WorkingDirectory();
            process.StartInfo.Arguments        = BuildArguments();



            process.Start();

            StreamWriter writer = process.StandardInput;

            writer.Write(ChainSpec());
            writer.Close();

            process.WaitForExit();
            CopyTheConstractFiles(ProcessInfo.Contracts);
        }
Example #2
0
        private static void CreateDbIfNotExists(IHost host)
        {
            using var scope = host.Services.CreateScope();
            var services = scope.ServiceProvider;
            var logger   = services.GetRequiredService <ILogger <Program> >();
            var dbPath   = Path.Combine(Core.Environment.GetAppDataFolder(), "tippy-db.db");

            if (File.Exists(dbPath))
            {
                logger.LogWarning("the db path: " + dbPath + " is exist;");
            }
            else
            {
                logger.LogWarning("the db path: " + dbPath + " is  not exist;");
            }
            logger.LogWarning("the working path: " + WorkPathManage.WorkingScriptDirectory(0));

            try
            {
                var context = services.GetRequiredService <Core.Data.TippyDbContext>();
                context.Database.Migrate();
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "An error occurred creating the DB.");
            }
        }
Example #3
0
        public IActionResult OnPost()
        {
            using (var fileStream = new FileStream(Path.Combine(WorkPathManage.ScriptDirectory(), FileUpload.UploadPrivateSchedule.FileName), FileMode.Create))
            {
                FileUpload.UploadPrivateSchedule.CopyTo(fileStream);
            }

            return(RedirectToPage("./Index"));
        }
Example #4
0
 protected override void Configure()
 {
     process = new System.Diagnostics.Process();
     process.StartInfo.UseShellExecute = false;
     //process.StartInfo.FileName = BinaryFullPath("ckb-indexer.exe");
     process.StartInfo.FileName         = BinaryFullPath(WorkPathManage.CkbForPaltform(ckbenum.ckbindexer));
     process.StartInfo.WorkingDirectory = WorkingDirectory();
     process.StartInfo.Arguments        = $"-s indexer-data -c http://127.0.0.1:{ProcessInfo.NodeRpcPort} -l 127.0.0.1:{ProcessInfo.IndexerRpcPort}";
 }
Example #5
0
        protected override void Configure()
        {
            UpdateConfiguration();

            process = new System.Diagnostics.Process();
            process.StartInfo.UseShellExecute = false;

            process.StartInfo.FileName         = BinaryFullPath(WorkPathManage.CkbForPaltform(ckbenum.ckb));
            process.StartInfo.WorkingDirectory = WorkingDirectory();
            process.StartInfo.Arguments        = "miner";
        }
        /// <summary>
        /// domain: return  List<Domain_ConstractFile>
        /// </summary>
        /// <returns></returns>
        public List <Domain_ConstractFile> GetConstractFiles()
        {
            List <Domain_ConstractFile> list = new List <Domain_ConstractFile>();

            WorkPathManage.GetListOfConstractFiles().ForEach(item =>
            {
                list.Add(new Domain_ConstractFile()
                {
                    filename       = item.Name,
                    filepath       = item.FullName,
                    filecreatetime = item.CreationTime,
                    modifytime     = item.LastWriteTime,
                });
            });
            return(list);
        }
Example #7
0
        public void OnGet()
        {
            ConstractFiles = WorkPathManage.GetListOfConstractFiles().Select(item => new Domain_ConstractFile {
                filename = item.Name, filepath = item.FullName
            }).ToList();
            var calculatingFromUsed = Projects.Count > 0;
            var rpcPorts            = Projects.Select(p => p.NodeRpcPort);
            var networkPorts        = Projects.Select(p => p.NodeNetworkPort);
            var indexerPorts        = Projects.Select(p => p.IndexerRpcPort);

            Project = new Project
            {
                Name            = $"CKB Chain",
                Chain           = Project.ChainType.Dev,
                NodeRpcPort     = calculatingFromUsed ? rpcPorts.Max() + 3 : 8114,
                NodeNetworkPort = calculatingFromUsed ? networkPorts.Max() + 3 : 8115,
                IndexerRpcPort  = calculatingFromUsed ? indexerPorts.Max() + 3 : 8116,
                LockArg         = "0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7"
            };
        }
Example #8
0
        protected override void Configure()
        {
            string?workingDirectory = Path.GetDirectoryName(TxFilePath);

            if (workingDirectory == null)
            {
                throw new Exception("No file path found!");
            }
            string debuggerBinaryPath = BinaryFullPath(WorkPathManage.CkbForPaltform(ckbenum.ckbdebugger));
            string arguments          = $"--port 7682 {debuggerBinaryPath} -l 0.0.0.0:2000 -g {ScriptGroupType} -h {ScriptHash} -t {TxFilePath} -e {IoType} -i {IoIndex}";

            if (BinaryPath != null)
            {
                arguments += $" -r {BinaryPath}";
            }
            process = new System.Diagnostics.Process();
            process.StartInfo.UseShellExecute  = false;
            process.StartInfo.FileName         = "ttyd";
            process.StartInfo.WorkingDirectory = workingDirectory;
            process.StartInfo.Arguments        = arguments;
        }