static async Task Main(string[] args) { ConfigurationBuilder builder = new ConfigurationBuilder(); //builder.AddUserSecrets<OTHubSettings>(); builder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false); IConfigurationRoot configuration = builder.Build(); var settings = new OTHubSettings(); configuration.Bind("OTHub", settings); settings.Validate(); //Add any new tables, indexes, columns etc to the database. This can only be used to upgrade somewhat recent databases. DatabaseUpgradeTask.Execute(); await RabbitMqService.Connect(); await SmartContractManager.Load(); Bootstrapper bootstrapper = new Bootstrapper(); bootstrapper.RunUntilExit(); }
public override async Task <bool> Execute(Source source, BlockchainType blockchain, BlockchainNetwork network) { ClientBase.ConnectionTimeout = new TimeSpan(0, 0, 5, 0); await using (var connection = new MySqlConnection(OTHubSettings.Instance.MariaDB.ConnectionString)) { int blockchainID = await GetBlockchainID(connection, blockchain, network); string currentHubAddress = await connection.ExecuteScalarAsync <string>("select HubAddress from blockchains where id = @id", new { id = blockchainID }); var allHubAddresses = new List <String>(); allHubAddresses.Add(currentHubAddress); var addresses = allHubAddresses.Distinct(); foreach (var address in addresses) { await PopulateSmartContracts(connection, address, address == currentHubAddress, blockchainID, blockchain, network); } } await SmartContractManager.Load(); return(true); }