Beispiel #1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            SetNetType(args);
            SetIsLoadTransRecord(args);
            SetIsExplorer(args);
            try
            {
                BlockchainJob.Initialize();
                BlockchainJob.Current.Start();
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message, ex);
            }
        }
Beispiel #2
0
        public static void Initialize()
        {
            var notify = new NotifyComponent();
            BlockchainComponent blockChainComponent = new BlockchainComponent();
            AccountComponent    accountComponent    = new AccountComponent();

            BlockchainJob.Current = new BlockchainJob();

            BlockDac.Default.GetAccountByLockScript = BlockchainJob.Current.GetAccountByLockScript;

            //从配置文件中读取
            ConfigurationTool tool = new ConfigurationTool();

            config = tool.GetAppSettings <NodeConfig>("NodeConfig");
            if (config == null)
            {
                GlobalParameters.IsPool = false;
                config = new NodeConfig();
            }
            else
            {
                notify.SetCallbackApp(config.WalletNotify);
                BlockchainJob.Current.P2PJob.LocalIP = config.LocalIP;
                GlobalParameters.IsPool = config.IsPool;
            }

            ConfigCenter.ConfigNode = config;



            //TODO 待验证删除
            //if (config != null)
            //{
            //    notify.SetCallbackApp(config.WalletNotify);
            //    BlockchainJob.Current.P2PJob.IPAddress = config.Ip;
            //    GlobalParameters.IsPool = config.IsPool;
            //}
            //else
            //{
            //    GlobalParameters.IsPool = false;
            //}

            if (GlobalActions.TransactionNotifyAction == null)
            {
                GlobalActions.TransactionNotifyAction = NewTransactionNotify;
            }

            blockChainComponent.Initialize();
            var accounts = AccountDac.Default.GetAccountBook();

            if (accounts.Count == 0)
            {
                var account = accountComponent.GenerateNewAccount(false);
                accountComponent.SetDefaultAccount(account.Id);
            }

            var defaultAccount = AppDac.Default.GetDefaultAccount();

            if (string.IsNullOrEmpty(defaultAccount))
            {
                var first = AccountDac.Default.GetAccountBook().FirstOrDefault();
                UserSettingComponent component = new UserSettingComponent();
                component.SetDefaultAccount(first);
            }

            TransactionPool.Instance.Load();
        }