Ejemplo n.º 1
0
 internal static void Start(MQConnectionPool mqpool)
 {
     _mqpool = mqpool;
     _dbContext = new DbContext().ConnectionString(Config.DBConnectString, new MySqlProvider());
     StartSignWatcher();
     StartSubmiterWatcher();
 }
Ejemplo n.º 2
0
        internal static void Start(MQConnectionPool mqpool)
        {
            if (UserRegisterWatcher.Started)
            {
                Log.Info("用户注册监控器启动");
                return;
            }
            _mqpool = mqpool;

            StartAutoActiveWalletConsumer();
        }
Ejemplo n.º 3
0
        internal static void Start(MQConnectionPool mqpool)
        {
            Check.Argument.IsNotNull(mqpool, "mqpool");

            Log.Info("正在转入交易监控器...");
            _mqpool = mqpool;

            StartOutboundTxConfirmConsumer();

            Log.Info("启动转入交易监控器成功!");
        }
Ejemplo n.º 4
0
        internal static void Start(MQConnectionPool mqpool)
        {
            if (NXTAccountGenerator.Started)
            {
                Log.Info("NXT充值地址生成器已启动");
                return;
            }

            nxtClient = new NXTClient4Net(Config.NXTServer, Config.SecretPhrase);
            _mqpool = mqpool;
            var currencies = Enum.GetValues(typeof(CurrencyType)).Cast<CurrencyType>();

            if (!Enum.TryParse<CurrencyType>(Config.CoinCode, out _currency))
            {
                Log.Error("配置文件中的CoinCode配置错误:错误值为{0},请使用正确的虚拟币Code", Config.CoinCode);
            }

            StartGenerateNewAddressConsumer(_currency);
        }
Ejemplo n.º 5
0
        internal static void Start(MQConnectionPool mqpool)
        {
            if (NXTBalanceWatcher.Started)
            {
                Log.Info("{0}余额监控器已启动", Config.CoinCode);
                return;
            }
            _nxtclient = new NXTClient4Net(Config.NXTServer, Config.SecretPhrase);
            _dbContext = new DbContext().ConnectionString(Config.DBConnectString, new MySqlProvider());
            _mqpool = mqpool;

            var currencies = Enum.GetValues(typeof(CurrencyType)).Cast<CurrencyType>();

            if (!Enum.TryParse<CurrencyType>(Config.CoinCode, out _currency))
            {
                Log.Error("配置文件中的CoinCode配置错误:错误值为{0},请使用正确的虚拟币Code", Config.CoinCode);
            }

            StartNXTBalanceWatcher(_currency);
        }
Ejemplo n.º 6
0
        internal static void Start(MQConnectionPool mqpool)
        {
            if (NXTSendTransactionListener.Started)
            {
                Log.Info("{0}提现处理器已启动", Config.CoinCode);
                return;
            }

            nxtClient = new NXTClient4Net(Config.NXTServer, Config.SecretPhrase);
            _mqpool = mqpool;

            var currencies = Enum.GetValues(typeof(CurrencyType)).Cast<CurrencyType>();

            if (!Enum.TryParse<CurrencyType>(Config.CoinCode, out _currency))
            {
                Log.Error("配置文件中的CoinCode配置错误:错误值为{0},请使用正确的虚拟币Code", Config.CoinCode);
            }

            StartSendPaymentTransactionConsumer(_currency);
        }
Ejemplo n.º 7
0
        internal static void Start(MQConnectionPool mqpool)
        {
            if (NXTReceiveTransactionListener.Started)
            {
                Log.Info("NXT到款交易监听器已启动");
                return;
            }

            _mqpool = mqpool;
            nxtClient = new NXTClient4Net(Config.NXTServer, Config.SecretPhrase);
            _dbContext = new DbContext().ConnectionString(Config.DBConnectString, new MySqlProvider());

            if (!Enum.TryParse<CurrencyType>(Config.CoinCode, out _currency))
            {
                Log.Error("配置文件中的CoinCode配置错误:错误值为{0},请使用正确的虚拟币Code", Config.CoinCode);
            }

            var thread = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    if (!NXTReceiveTransactionListener.Started)
                    {
                        Log.Info("{0}到款交易监听器启动成功,监听交易中...", Config.CoinCode);
                        NXTReceiveTransactionListener.Started = true;
                    }
                    if (Program.Fusing)
                    {
                        Log.Info("发生熔断事件,虚拟币交易监听器停止运行");
                        _cancelTokenSource.Cancel();
                        break;
                    }

                    var isProcessToEnd = false;
                    var offset = 0;

                    while (!isProcessToEnd)
                    {
                        var nxtAccounts = GetNXTAccounts(offset);

                        if (nxtAccounts != null && nxtAccounts.Count() > 0)
                        {
                            offset = nxtAccounts.Last().ID;

                            nxtAccounts.AsParallel().ForAll(nc =>
                            {
                                var txIds = GetTxIds(nc.UserID, nc.NxtAccountID, 0);

                                if (txIds != null && txIds.TransactionIds.Length > 0)
                                {
                                    txIds.TransactionIds.ForEach(txid =>
                                    {
                                        if (!ExistTx(nc.Address, txid, _currency))
                                        {
                                            var tx = default(GetTransactionResponse);

                                            if (TryGetTransaction(txid, out tx)) ProcessTx(nc.UserID, tx, nc.NxtAccountID, _currency);
                                        }
                                    });
                                }
                            });
                        }
                        else isProcessToEnd = true;
                    }

                    Thread.Sleep(Config.LoopInterval * 1000);
                }
            }));

            thread.Start();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            if (!IsRuning())
            {
                Fusing = false; //熔断
                InitializeEnvironment();

                var mqpool = new MQConnectionPool(Config.MQConnectString);
                InboundTxProcessor.Start(mqpool);
                OutboundTxProcessor.Start(mqpool);
                //NXTAccountGenerator.Start(mqpool);
                //NXTTransactionConfirmationValidator.Start(mqpool);
                //NXTSendTransactionListener.Start(mqpool);

                while (true)
                {
                    if (Fusing)
                        break;
                    else
                    {
                        Console.Read();
                        Thread.Sleep(60 * 1000);
                    }
                }

                Stop();
            }
            else
            {
                Console.WriteLine("监控器已启动,请勿重复启动监控!");
                Console.WriteLine("输入任意键结束...");
                Console.Read();
            }

            Console.Read();
        }
        internal static void Start(MQConnectionPool mqpool)
        {
            if (NXTTransactionConfirmationValidator.Started)
            {
                Log.Info("{0}转账确认验证器已启动", Config.CoinCode);
                return;
            }

            nxtClient = new NXTClient4Net(Config.NXTServer, Config.SecretPhrase);
            _dbContext = new DbContext().ConnectionString(Config.DBConnectString, new MySqlProvider());
            _mqpool = mqpool;

            if (!Enum.TryParse<CurrencyType>(Config.CoinCode, out _currency))
            {
                Log.Error("配置文件中的CoinCode配置错误:错误值为{0},请使用正确的虚拟币Code", Config.CoinCode);
            }

            var thread = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    if (!NXTTransactionConfirmationValidator.Started)
                    {
                        Log.Info("{0}转账确认验证器启动成功", Config.CoinCode);
                        NXTTransactionConfirmationValidator.Started = true;
                    }

                    if (Program.Fusing)
                    {
                        Log.Info("发生熔断事件,虚拟币转账确认验证器停止运行");
                        break;
                    }

                    var unconfirmTxs = GetUnconfirmPaymentTransactions().ToList();

                    if (unconfirmTxs != null && unconfirmTxs.Count() > 0)
                    {
                        var needConfirmations = GetNeedConfirmationCount(_currency);

                        for (int i = 0; i < unconfirmTxs.Count(); i++)
                        {
                            var tx = unconfirmTxs[i];

                            var txRepos = default(GetTransactionResponse);

                            if (TryGetTransaction(tx.TxID, out txRepos))
                            {
                                if (txRepos.Confirmations >= needConfirmations)
                                {
                                    ProcessTx(txRepos, _currency);
                                }
                                else
                                {
                                    Log.Info("txid={0}的交易确认不足{1}个,等待下次处理", tx.TxID, needConfirmations);
                                }
                            }
                        }
                    }

                    Thread.Sleep(Config.LoopInterval * 1000);
                }
            }));

            thread.Start();
        }
Ejemplo n.º 10
0
        internal static void Start(MQConnectionPool mqpool)
        {
            if (RippleInboundTransferWatcher.Started)
            {
                Log.Info("Ripple转入交易监听器已启动");
                return;
            }

            currentProcessLedgerIndex = GetLastProcessLedgerIndex();

            _mqpool = mqpool;

            _dbContext = new DbContext().ConnectionString(Config.DBConnectString, new MySqlProvider());

            var thread = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    if (!RippleInboundTransferWatcher.Started)
                    {
                        Log.Info("Ripple转入交易监听器启动成功,监听交易中...");
                        RippleInboundTransferWatcher.Started = true;
                    }
                    if (Program.Fusing)
                    {
                        Log.Info("发生熔断事件,Ripple转入交易监听器停止运行");
                        _cancelTokenSource.Cancel();
                        break;
                    }

                    if (!waitCallback)
                    {
                        var rippleClient = IoC.Resolve<IRippleClientAsync>();
                        var aviableLedgerIndexResult = rippleClient.GetClosedLedgerIndex().Result;
                        if (aviableLedgerIndexResult.Item1 == null)
                        {
                            var ledger_min = RippleInboundTransferWatcher.currentProcessLedgerIndex;
                            var ledgerIndex_max = ledger_min + Config.Step - 1; //因为ripple走的是一个 ≥和≤的区间,所以+99就是一次分析100个ledger
                            ledgerIndex_max = Math.Min(ledgerIndex_max, aviableLedgerIndexResult.Item2 - 12);//取小值

                            if (ledgerIndex_max < ledger_min)
                            {
                                Log.Warn("目前已到达最新的ledger-" + RippleInboundTransferWatcher.currentProcessLedgerIndex + ",等待ledger close后再进行解析");
                            }
                            else
                            {
                                lock (_lock)
                                {
                                    waitCallback = true;

                                    GetTxs(ledger_min, ledgerIndex_max, ProcessTxs);
                                }
                            }
                        }
                    }
                    else
                        Thread.Sleep(3 * 1000);
                }
            }));

            thread.Start();
        }