Beispiel #1
0
        async static Task Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddCommandLine(args);

#if DEBUG
            builder = builder.AddUserSecrets <Program>();
#else
            builder = builder.AddAzureKeyVault("https://testnetvaultbiz.vault.azure.net/");
#endif
            IConfigurationRoot configuration = builder.Build();

            var conf = new NodeConfig();
            configuration.GetSection("Node").Bind(conf);
            repository = new WithdrawInfoRepository();
            var connector = new CryptoConnector(conf.OracleETHAddres, conf.OracleBTCAddres, conf.ETHEndpoint, conf.BTCEndpoint);
            var miner     = new Miner(new PeerListener(conf.ListenPort), new WalletRepository(),
                                      new BlockRepository(), new BalanceRepository(), new BookRepository(),
                                      new DepositRepository(), new OfferRepository(), new TransactionRepository(),
                                      new WithdrawalRepository(), new TradeRepository(), repository,
                                      connector);

            reader = miner.GetChainStream();

            await miner.Start(true);

            WithdrawListener(miner, connector, configuration.GetValue <string>("BTCSECRET"), configuration.GetValue <string>("ETHSECRET"), conf);

            if (!string.IsNullOrEmpty(conf.SeedAddress) && conf.SeedPort > 0)
            {
                try
                {
                    var seednode = new Peer(new TcpClient(conf.SeedAddress, conf.SeedPort));
                    miner.Connect(seednode);
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                    throw;
                }
            }
            await Task.Delay(Timeout.Infinite);
        }
Beispiel #2
0
        async static Task Main(string[] args)
        {
            Console.WriteLine("Starting Oracle");
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("pkcscfg.json", optional: false, reloadOnChange: true)
                          .AddCommandLine(args);


            IConfigurationRoot configuration = builder.Build();

            Log.Debug("Building Config");

            var conf = new NodeConfig();

            configuration.GetSection("Node").Bind(conf);
            var pkcsConf = new PKCS();

            configuration.GetSection("PKCS").Bind(pkcsConf);
            Log.Debug("NodeConfig created");

            repository = new WithdrawInfoRepository();
            var wdRepository = new WithdrawalRepository();
            var connector    = new CryptoConnector(conf.OracleETHAddres, conf.OracleBTCAddres, conf.ETHEndpoint, conf.BTCEndpoint, conf.Network);
            var miner        = new Miner(new PeerListener(conf.ListenPort), new WalletRepository(),
                                         new BlockRepository(), new BalanceRepository(), new BookRepository(),
                                         new DepositRepository(), new OfferRepository(), new TransactionRepository(),
                                         wdRepository, new TradeRepository(), repository,
                                         connector, conf.ListenPort, true, 1000, true);

            ethConnector = new EthereumOracleConnector(conf.ETHEndpoint, conf.OracleETHAddres, pkcsConf.User, pkcsConf.EthKey);
            btcConnector = new BitcoinOracleConnector(conf.Network, conf.BTCEndpoint, pkcsConf.User, pkcsConf.BtcKey);

            if (conf.Reprocess)
            {
                Log.Information("Reprocessing withdraws: ");
                foreach (var wdid in await repository.ListToReprocess())
                {
                    Log.Information("Reprocessing withdraw: " + wdid);
                    var wd = await wdRepository.Get(wdid);

                    await ProcessWithdraw(wd);
                }
            }

            reader = miner.GetChainStream();

            await miner.Start(true);

            WithdrawListener(miner, connector, conf);

            if (!string.IsNullOrEmpty(conf.SeedAddress) && conf.SeedPort > 0)
            {
                try
                {
                    var seednode = new Peer(new TcpClient(conf.SeedAddress, conf.SeedPort));
                    miner.Connect(seednode);
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                    throw;
                }
            }
            await Task.Delay(Timeout.Infinite);
        }